Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document traits in std::num (#7511)
  • Loading branch information
Manishearth committed Apr 11, 2014
1 parent b2b2bbb commit 01d5d51
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libstd/num/mod.rs
Expand Up @@ -159,6 +159,7 @@ pub fn abs_sub<T: Signed>(x: T, y: T) -> T {
/// - `-1` if the number is negative
#[inline(always)] pub fn signum<T: Signed>(value: T) -> T { value.signum() }

/// A trait for values which cannot be negative
pub trait Unsigned: Num {}

/// A collection of rounding operations.
Expand Down Expand Up @@ -205,6 +206,7 @@ pub fn pow<T: One + Mul<T, T>>(mut base: T, mut exp: uint) -> T {
}
}

/// Numbers which have upper and lower bounds
pub trait Bounded {
// FIXME (#5527): These should be associated constants
fn min_value() -> Self;
Expand Down Expand Up @@ -1046,10 +1048,12 @@ impl_num_cast!(int, to_int)
impl_num_cast!(f32, to_f32)
impl_num_cast!(f64, to_f64)

/// A generic trait for converting a value to a string with a radix (base)
pub trait ToStrRadix {
fn to_str_radix(&self, radix: uint) -> ~str;
}

/// A generic trait for converting a string with a radix (base) to a value
pub trait FromStrRadix {
fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
}
Expand Down

9 comments on commit 01d5d51

@bors
Copy link
Contributor

@bors bors commented on 01d5d51 Apr 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at Manishearth@01d5d51

@bors
Copy link
Contributor

@bors bors commented on 01d5d51 Apr 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Manishearth/rust/docnum = 01d5d51 into auto

@bors
Copy link
Contributor

@bors bors commented on 01d5d51 Apr 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manishearth/rust/docnum = 01d5d51 merged ok, testing candidate = d4bfe2d4

@bors
Copy link
Contributor

@bors bors commented on 01d5d51 Apr 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 01d5d51 Apr 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at Manishearth@01d5d51

@bors
Copy link
Contributor

@bors bors commented on 01d5d51 Apr 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Manishearth/rust/docnum = 01d5d51 into auto

@bors
Copy link
Contributor

@bors bors commented on 01d5d51 Apr 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manishearth/rust/docnum = 01d5d51 merged ok, testing candidate = 296e60b

@bors
Copy link
Contributor

@bors bors commented on 01d5d51 Apr 13, 2014

@bors
Copy link
Contributor

@bors bors commented on 01d5d51 Apr 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 296e60b

Please sign in to comment.