]> git.proxmox.com Git - rustc.git/blame - src/test/ui/traits/inheritance/auxiliary/overloading_xc.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / traits / inheritance / auxiliary / overloading_xc.rs
CommitLineData
1a4d82fc
JJ
1use std::cmp::PartialEq;
2use std::ops::{Add, Sub, Mul};
223e47cc 3
1a4d82fc 4pub trait MyNum : Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + PartialEq + Clone {
223e47cc
LB
5}
6
85aaf69f 7#[derive(Clone, Debug)]
223e47cc 8pub struct MyInt {
c34b1796 9 pub val: isize
223e47cc
LB
10}
11
1a4d82fc
JJ
12impl Add for MyInt {
13 type Output = MyInt;
14
15 fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) }
223e47cc
LB
16}
17
1a4d82fc
JJ
18impl Sub for MyInt {
19 type Output = MyInt;
20
21 fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) }
223e47cc
LB
22}
23
1a4d82fc
JJ
24impl Mul for MyInt {
25 type Output = MyInt;
26
27 fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) }
223e47cc
LB
28}
29
1a4d82fc 30impl PartialEq for MyInt {
223e47cc
LB
31 fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
32
33 fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
34}
35
1a4d82fc 36impl MyNum for MyInt {}
223e47cc 37
c34b1796 38fn mi(v: isize) -> MyInt { MyInt { val: v } }