mirror of https://github.com/rust-lang/rust.git
core: add min and max to cmp, re-export various places.
This commit is contained in:
parent
d06e6e758a
commit
389125aeb8
|
@ -85,3 +85,12 @@ pub pure fn gt<T: Ord>(v1: &T, v2: &T) -> bool {
|
|||
(*v1).gt(v2)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn min<T: Ord>(v1: T, v2: T) -> T {
|
||||
if v1 < v2 { v1 } else { v2 }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn max<T: Ord>(v1: T, v2: T) -> T {
|
||||
if v1 > v2 { v1 } else { v2 }
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ use to_str;
|
|||
use from_str;
|
||||
|
||||
pub use cmath::c_double_targ_consts::*;
|
||||
pub use cmp::{min, max};
|
||||
|
||||
macro_rules! delegate(
|
||||
(
|
||||
|
|
|
@ -24,6 +24,7 @@ use vec;
|
|||
use i8;
|
||||
use i16;
|
||||
use i32;
|
||||
pub use cmp::{min, max};
|
||||
|
||||
pub const bits : uint = inst::bits;
|
||||
pub const bytes : uint = (inst::bits / 8);
|
||||
|
@ -31,11 +32,6 @@ pub const bytes : uint = (inst::bits / 8);
|
|||
pub const min_value: T = (-1 as T) << (bits - 1);
|
||||
pub const max_value: T = min_value - 1 as T;
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn min(x: T, y: T) -> T { if x < y { x } else { y } }
|
||||
#[inline(always)]
|
||||
pub pure fn max(x: T, y: T) -> T { if x > y { x } else { y } }
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn add(x: T, y: T) -> T { x + y }
|
||||
#[inline(always)]
|
||||
|
|
|
@ -27,17 +27,14 @@ use u8;
|
|||
use u16;
|
||||
use u32;
|
||||
|
||||
pub use cmp::{min, max};
|
||||
|
||||
pub const bits : uint = inst::bits;
|
||||
pub const bytes : uint = (inst::bits / 8);
|
||||
|
||||
pub const min_value: T = 0 as T;
|
||||
pub const max_value: T = 0 as T - 1 as T;
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn min(x: T, y: T) -> T { if x < y { x } else { y } }
|
||||
#[inline(always)]
|
||||
pub pure fn max(x: T, y: T) -> T { if x > y { x } else { y } }
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn add(x: T, y: T) -> T { x + y }
|
||||
#[inline(always)]
|
||||
|
|
Loading…
Reference in New Issue