about summary refs log tree commit diff
path: root/tests/ui/traits/inheritance/num0.rs
blob: a170388b49453404530f4d323f6726d54a89acd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//@ run-pass
#![allow(dead_code)]
// Extending Num and using inherited static methods


pub trait NumCast: Sized {
    fn from(i: i32) -> Option<Self>;
}

pub trait Num {
    fn from_int(i: isize) -> Self;
    fn gt(&self, other: &Self) -> bool;
}

pub trait NumExt: NumCast + PartialOrd { }

fn greater_than_one<T:NumExt>(n: &T) -> bool {
    n.gt(&NumCast::from(1).unwrap())
}

pub fn main() {}