2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2012-11-28 20:34:30 +00:00
|
|
|
// Extending Num and using inherited static methods
|
|
|
|
|
2015-03-22 20:13:15 +00:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2014-11-10 00:30:52 +00:00
|
|
|
use std::cmp::PartialOrd;
|
2015-04-18 05:12:20 +00:00
|
|
|
|
2015-12-15 09:31:58 +00:00
|
|
|
pub trait NumCast: Sized {
|
2015-04-18 05:12:20 +00:00
|
|
|
fn from(i: i32) -> Option<Self>;
|
|
|
|
}
|
2012-11-28 20:34:30 +00:00
|
|
|
|
2014-09-19 19:30:07 +00:00
|
|
|
pub trait Num {
|
2015-03-26 00:06:52 +00:00
|
|
|
fn from_int(i: isize) -> Self;
|
2013-01-31 03:42:06 +00:00
|
|
|
fn gt(&self, other: &Self) -> bool;
|
2012-11-28 20:34:30 +00:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:52 +00:00
|
|
|
pub trait NumExt: NumCast + PartialOrd { }
|
2012-11-28 20:34:30 +00:00
|
|
|
|
|
|
|
fn greater_than_one<T:NumExt>(n: &T) -> bool {
|
2015-01-25 21:05:03 +00:00
|
|
|
n.gt(&NumCast::from(1).unwrap())
|
2012-11-28 20:34:30 +00:00
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {}
|