]> git.lizzy.rs Git - rust.git/blob - tests/ui/single_char_pattern.fixed
Remove all copyright license headers
[rust.git] / tests / ui / single_char_pattern.fixed
1 // run-rustfix
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     // Not yet testing for multi-byte characters
14     // Changing `r.len() == 1` to `r.chars().count() == 1` in `lint_clippy::single_char_pattern`
15     // should have done this but produced an ICE
16     //
17     // We may not want to suggest changing these anyway
18     // See: https://github.com/rust-lang/rust-clippy/issues/650#issuecomment-184328984
19     x.split("ß");
20     x.split("ℝ");
21     x.split("💣");
22     // Can't use this lint for unicode code points which don't fit in a char
23     x.split("❤️");
24     x.contains('x');
25     x.starts_with('x');
26     x.ends_with('x');
27     x.find('x');
28     x.rfind('x');
29     x.rsplit('x');
30     x.split_terminator('x');
31     x.rsplit_terminator('x');
32     x.splitn(0, 'x');
33     x.rsplitn(0, 'x');
34     x.matches('x');
35     x.rmatches('x');
36     x.match_indices('x');
37     x.rmatch_indices('x');
38     x.trim_start_matches('x');
39     x.trim_end_matches('x');
40     // Make sure we escape characters correctly.
41     x.split('\n');
42
43     let h = HashSet::<String>::new();
44     h.contains("X"); // should not warn
45
46     x.replace(";", ",").split(','); // issue #2978
47     x.starts_with('\x03'); // issue #2996
48
49     // Issue #3204
50     const S: &str = "#";
51     x.find(S);
52 }