]> git.lizzy.rs Git - rust.git/blob - tests/ui/starts_ends_with.rs
Adapt the *.stderr files of the ui-tests to the tool_lints
[rust.git] / tests / ui / starts_ends_with.rs
1 #![feature(tool_lints)]
2
3 #![allow(dead_code)]
4
5 fn main() {}
6
7 #[allow(clippy::unnecessary_operation)]
8 fn starts_with() {
9     "".chars().next() == Some(' ');
10     Some(' ') != "".chars().next();
11 }
12
13 fn chars_cmp_with_unwrap() {
14     let s = String::from("foo");
15     if s.chars().next().unwrap() == 'f' { // s.starts_with('f')
16         // Nothing here
17     }
18     if s.chars().next_back().unwrap() == 'o' { // s.ends_with('o')
19         // Nothing here
20     }
21     if s.chars().last().unwrap() == 'o' { // s.ends_with('o')
22         // Nothing here
23     }
24     if s.chars().next().unwrap() != 'f' { // !s.starts_with('f')
25         // Nothing here
26     }
27     if s.chars().next_back().unwrap() != 'o' { // !s.ends_with('o')
28         // Nothing here
29     }
30     if s.chars().last().unwrap() != 'o' { // !s.ends_with('o')
31         // Nothing here
32     }
33 }
34
35 #[allow(clippy::unnecessary_operation)]
36 fn ends_with() {
37     "".chars().last() == Some(' ');
38     Some(' ') != "".chars().last();
39     "".chars().next_back() == Some(' ');
40     Some(' ') != "".chars().next_back();
41 }