rust/tests/ui/traits/inheritance/num0.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
455 B
Rust
Raw Normal View History

// run-pass
#![allow(dead_code)]
// Extending Num and using inherited static methods
// pretty-expanded FIXME #23616
2014-11-10 00:30:52 +00:00
use std::cmp::PartialOrd;
2015-04-18 05:12:20 +00:00
pub trait NumCast: Sized {
2015-04-18 05:12:20 +00:00
fn from(i: i32) -> Option<Self>;
}
pub trait Num {
fn from_int(i: isize) -> Self;
fn gt(&self, other: &Self) -> bool;
}
2014-11-10 00:30:52 +00:00
pub trait NumExt: NumCast + PartialOrd { }
fn greater_than_one<T:NumExt>(n: &T) -> bool {
2015-01-25 21:05:03 +00:00
n.gt(&NumCast::from(1).unwrap())
}
pub fn main() {}