Open
Description
I love the new lints! But I found what seems to be a false positive:
For the following code:
pub fn from_bigml<S: Into<String>>(name: S) -> Result<FieldName> {
// Again, we have a fair bit of internal knowledge about what kinds of
// field names can actually exist. Don't hesitate to add new types.
lazy_static! {
static ref PRIVATE_RE: Regex = Regex::new("^private_").unwrap();
}
let name = name.into();
Self::from_unescaped(PRIVATE_RE.replace(&name, "private/"))
}
...the trivial_regex
lint suggests:
warning: trivial regex
--> src/types/field_name.rs:80:55
|
80 | static ref PRIVATE_RE: Regex = Regex::new("^private_").unwrap();
| ^^^^^^^^^^^
|
= note: #[warn(trivial_regex)] on by default
= help: consider using consider using `str::starts_with`
= help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#trivial_regex
Not all regular expressions are used for matches, and I'm not aware of anything in std
that implements "replace this string only at the beginning of another string."