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