mirror of
				https://git.proxmox.com/git/rustc
				synced 2025-10-31 07:17:23 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			350 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			350 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| extern crate overload;
 | |
| use overload::overload;
 | |
| use std::ops;
 | |
| 
 | |
| #[derive(PartialEq, Debug)]
 | |
| struct A(i32);
 | |
| 
 | |
| #[derive(PartialEq, Debug)]
 | |
| struct B(i32);
 | |
| 
 | |
| overload!(- (a: A) -> B { B(-a.0) });
 | |
| #[test]
 | |
| fn neg() {
 | |
|     assert_eq!(-A(3), B(-3));
 | |
| }
 | |
| 
 | |
| overload!(! (a: A) -> B { B(!a.0) });
 | |
| #[test]
 | |
| fn not() {
 | |
|     assert_eq!(!A(3), B(!3));
 | |
| }
 | 
