2014-02-07 19:08:32 +00:00
|
|
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
2012-12-11 01:32:48 +00:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
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
|
|
|
|
|
2015-03-06 02:33:58 +00:00
|
|
|
#![feature(core)]
|
|
|
|
|
2014-11-10 00:30:52 +00:00
|
|
|
use std::cmp::PartialOrd;
|
2013-05-21 00:07:24 +00:00
|
|
|
use std::num::NumCast;
|
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() {}
|