]> git.lizzy.rs Git - rust.git/blob - tests/ui/op_ref.rs
iterate List by value
[rust.git] / tests / ui / op_ref.rs
1 #![allow(unused_variables, clippy::blacklisted_name)]
2 #![warn(clippy::op_ref)]
3 #![allow(clippy::many_single_char_names)]
4 use std::collections::HashSet;
5 use std::ops::BitAnd;
6
7 fn main() {
8     let tracked_fds: HashSet<i32> = HashSet::new();
9     let new_fds = HashSet::new();
10     let unwanted = &tracked_fds - &new_fds;
11
12     let foo = &5 - &6;
13
14     let bar = String::new();
15     let bar = "foo" == &bar;
16
17     let a = "a".to_string();
18     let b = "a";
19
20     if b < &a {
21         println!("OK");
22     }
23
24     struct X(i32);
25     impl BitAnd for X {
26         type Output = X;
27         fn bitand(self, rhs: X) -> X {
28             X(self.0 & rhs.0)
29         }
30     }
31     impl<'a> BitAnd<&'a X> for X {
32         type Output = X;
33         fn bitand(self, rhs: &'a X) -> X {
34             X(self.0 & rhs.0)
35         }
36     }
37     let x = X(1);
38     let y = X(2);
39     let z = x & &y;
40
41     #[derive(Copy, Clone)]
42     struct Y(i32);
43     impl BitAnd for Y {
44         type Output = Y;
45         fn bitand(self, rhs: Y) -> Y {
46             Y(self.0 & rhs.0)
47         }
48     }
49     impl<'a> BitAnd<&'a Y> for Y {
50         type Output = Y;
51         fn bitand(self, rhs: &'a Y) -> Y {
52             Y(self.0 & rhs.0)
53         }
54     }
55     let x = Y(1);
56     let y = Y(2);
57     let z = x & &y;
58 }