]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/src/docs/trivial_regex.txt
New upstream version 1.65.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / trivial_regex.txt
1 ### What it does
2 Checks for trivial [regex](https://crates.io/crates/regex)
3 creation (with `Regex::new`, `RegexBuilder::new`, or `RegexSet::new`).
4
5 ### Why is this bad?
6 Matching the regex can likely be replaced by `==` or
7 `str::starts_with`, `str::ends_with` or `std::contains` or other `str`
8 methods.
9
10 ### Known problems
11 If the same regex is going to be applied to multiple
12 inputs, the precomputations done by `Regex` construction can give
13 significantly better performance than any of the `str`-based methods.
14
15 ### Example
16 ```
17 Regex::new("^foobar")
18 ```