]> git.lizzy.rs Git - rust.git/blob - tests/ui/single_char_pattern.rs
Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
[rust.git] / tests / ui / single_char_pattern.rs
1 // run-rustfix
2
3 #![allow(unused_must_use)]
4
5 use std::collections::HashSet;
6
7 fn main() {
8     let x = "foo";
9     x.split("x");
10     x.split("xx");
11     x.split('x');
12
13     let y = "x";
14     x.split(y);
15     x.split("ß");
16     x.split("ℝ");
17     x.split("💣");
18     // Can't use this lint for unicode code points which don't fit in a char
19     x.split("❤️");
20     x.split_inclusive("x");
21     x.contains("x");
22     x.starts_with("x");
23     x.ends_with("x");
24     x.find("x");
25     x.rfind("x");
26     x.rsplit("x");
27     x.split_terminator("x");
28     x.rsplit_terminator("x");
29     x.splitn(2, "x");
30     x.rsplitn(2, "x");
31     x.split_once("x");
32     x.rsplit_once("x");
33     x.matches("x");
34     x.rmatches("x");
35     x.match_indices("x");
36     x.rmatch_indices("x");
37     x.trim_start_matches("x");
38     x.trim_end_matches("x");
39     x.strip_prefix("x");
40     x.strip_suffix("x");
41     x.replace("x", "y");
42     x.replacen("x", "y", 3);
43     // Make sure we escape characters correctly.
44     x.split("\n");
45     x.split("'");
46     x.split("\'");
47
48     let h = HashSet::<String>::new();
49     h.contains("X"); // should not warn
50
51     x.replace(';', ",").split(","); // issue #2978
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###"#"###);
64     // Must escape backslash in raw strings when converting to char #8060
65     x.split(r#"\"#);
66     x.split(r"\");
67 }