fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.5 KiB65 linesraw
1#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)]
2
3use std::collections::HashSet;
4
5fn 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("❤️");
18    x.split_inclusive('x');
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');
27    x.splitn(2, 'x');
28    x.rsplitn(2, 'x');
29    x.split_once('x');
30    x.rsplit_once('x');
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');
37    x.strip_prefix('x');
38    x.strip_suffix('x');
39    x.replace('x', "y");
40    x.replacen('x', "y", 3);
41    // Make sure we escape characters correctly.
42    x.split('\n');
43    x.split('\'');
44    x.split('\'');
45
46    let h = HashSet::<String>::new();
47    h.contains("X"); // should not warn
48
49    x.replace(';', ",").split(','); // issue #2978
50    x.starts_with('\x03'); // issue #2996
51
52    // Issue #3204
53    const S: &str = "#";
54    x.find(S);
55
56    // Raw string
57    x.split('a');
58    x.split('a');
59    x.split('a');
60    x.split('\'');
61    x.split('#');
62    // Must escape backslash in raw strings when converting to char #8060
63    x.split('\\');
64    x.split('\\');
65}