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