Rust

Rust

Made by DeepSource

Found trivial regex RS-W1027

Performance
Minor

Certain regexes that are used with Regex::new or RegexBuilder::new may be replaced by common str methods, such as str::starts_with, str::ends_with, str::contains and str::cmp.

Bad practice

let s = "Mary had a little lambda";

let re = Regex::new("^Mary").unwrap();
re.is_match(s);

let re = Regex::new("little").unwrap();
re.is_match(s);

Recommended

let s = "Mary had a little lambda";

s.starts_with("Mary");

s.contains("little");