Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. struct Sum(u32, u32);
  2.  
  3. impl PartialEq for Sum {
  4. fn eq(&self, other: &Self) -> bool { self.0 + self.1 == other.0 + other.1 }
  5. }
  6.  
  7. impl Eq for Sum { }
  8.  
  9. #[derive(PartialEq, Eq)]
  10. enum Eek {
  11. TheConst,
  12. UnusedByTheConst(Sum)
  13. }
  14.  
  15. const THE_CONST: Eek = Eek::TheConst;
  16.  
  17. pub fn main() {
  18. match Eek::UnusedByTheConst(Sum(1,2)) {
  19. THE_CONST => { println!("Hello"); }
  20. _ => { println!("Gbye"); }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement