]> git.proxmox.com Git - rustc.git/blame - src/test/ui/traits/trait-inheritance-overloading-simple.rs
New upstream version 1.51.0+dfsg1
[rustc.git] / src / test / ui / traits / trait-inheritance-overloading-simple.rs
CommitLineData
b7449926 1// run-pass
0bf4aa26 2#![allow(dead_code)]
1a4d82fc 3use std::cmp::PartialEq;
223e47cc 4
1a4d82fc 5trait MyNum : PartialEq { }
223e47cc 6
85aaf69f 7#[derive(Debug)]
c34b1796 8struct MyInt { val: isize }
223e47cc 9
1a4d82fc 10impl PartialEq for MyInt {
223e47cc
LB
11 fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
12 fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
13}
14
1a4d82fc 15impl MyNum for MyInt {}
223e47cc
LB
16
17fn f<T:MyNum>(x: T, y: T) -> bool {
18 return x == y;
19}
20
c34b1796 21fn mi(v: isize) -> MyInt { MyInt { val: v } }
223e47cc
LB
22
23pub fn main() {
24 let (x, y, z) = (mi(3), mi(5), mi(3));
25 assert!(x != y);
970d7e83 26 assert_eq!(x, z);
223e47cc 27}