]>
Commit | Line | Data |
---|---|---|
fe692bf9 | 1 | #![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] |
f20569fa XL |
2 | |
3 | use std::collections::HashSet; | |
4 | ||
5 | fn main() { | |
6 | let x = "foo"; | |
7 | x.split("x"); | |
8 | x.split("xx"); | |
9 | x.split('x'); | |
10 | ||
11 | let y = "x"; | |
12 | x.split(y); | |
13 | x.split("ß"); | |
14 | x.split("ℝ"); | |
15 | x.split("💣"); | |
16 | // Can't use this lint for unicode code points which don't fit in a char | |
17 | x.split("❤️"); | |
a2a8927a | 18 | x.split_inclusive("x"); |
f20569fa XL |
19 | x.contains("x"); |
20 | x.starts_with("x"); | |
21 | x.ends_with("x"); | |
22 | x.find("x"); | |
23 | x.rfind("x"); | |
24 | x.rsplit("x"); | |
25 | x.split_terminator("x"); | |
26 | x.rsplit_terminator("x"); | |
17df50a5 XL |
27 | x.splitn(2, "x"); |
28 | x.rsplitn(2, "x"); | |
a2a8927a XL |
29 | x.split_once("x"); |
30 | x.rsplit_once("x"); | |
f20569fa XL |
31 | x.matches("x"); |
32 | x.rmatches("x"); | |
33 | x.match_indices("x"); | |
34 | x.rmatch_indices("x"); | |
35 | x.trim_start_matches("x"); | |
36 | x.trim_end_matches("x"); | |
17df50a5 XL |
37 | x.strip_prefix("x"); |
38 | x.strip_suffix("x"); | |
a2a8927a XL |
39 | x.replace("x", "y"); |
40 | x.replacen("x", "y", 3); | |
f20569fa XL |
41 | // Make sure we escape characters correctly. |
42 | x.split("\n"); | |
43 | x.split("'"); | |
44 | x.split("\'"); | |
c0240ec0 FG |
45 | // Issue #11973: Don't escape `"` in `'"'` |
46 | x.split("\""); | |
f20569fa XL |
47 | |
48 | let h = HashSet::<String>::new(); | |
49 | h.contains("X"); // should not warn | |
50 | ||
a2a8927a | 51 | x.replace(';', ",").split(","); // issue #2978 |
f20569fa XL |
52 | x.starts_with("\x03"); // issue #2996 |
53 | ||
54 | // Issue #3204 | |
55 | const S: &str = "#"; | |
56 | x.find(S); | |
57 | ||
58 | // Raw string | |
59 | x.split(r"a"); | |
60 | x.split(r#"a"#); | |
61 | x.split(r###"a"###); | |
62 | x.split(r###"'"###); | |
63 | x.split(r###"#"###); | |
a2a8927a XL |
64 | // Must escape backslash in raw strings when converting to char #8060 |
65 | x.split(r#"\"#); | |
66 | x.split(r"\"); | |
f20569fa | 67 | } |