]> git.lizzy.rs Git - rust.git/blob - tests/ui/starts_ends_with.rs
Merge pull request #2126 from camsteffen/split-tests
[rust.git] / tests / ui / starts_ends_with.rs
1 #![allow(dead_code)]
2
3 fn main() {}
4
5 #[allow(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' { // s.starts_with('f')
14         // Nothing here
15     }
16     if s.chars().next_back().unwrap() == 'o' { // s.ends_with('o')
17         // Nothing here
18     }
19     if s.chars().last().unwrap() == 'o' { // s.ends_with('o')
20         // Nothing here
21     }
22     if s.chars().next().unwrap() != 'f' { // !s.starts_with('f')
23         // Nothing here
24     }
25     if s.chars().next_back().unwrap() != 'o' { // !s.ends_with('o')
26         // Nothing here
27     }
28     if s.chars().last().unwrap() != 'o' { // !s.ends_with('o')
29         // Nothing here
30     }
31 }
32
33 #[allow(unnecessary_operation)]
34 fn ends_with() {
35     "".chars().last() == Some(' ');
36     Some(' ') != "".chars().last();
37     "".chars().next_back() == Some(' ');
38     Some(' ') != "".chars().next_back();
39 }