Skip to content

Commit 4f65fc7

Browse files
committed
Improve std::num module description, and fix some formatting
1 parent b6ea053 commit 4f65fc7

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

src/libstd/num/num.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! An interface for numeric types
11+
//! Numeric traits and functions for generic mathematics.
12+
//!
13+
//! These are implemented for the primitive numeric types in `std::{u8, u16,
14+
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float}`.
1215
1316
#[allow(missing_doc)];
1417

@@ -19,9 +22,7 @@ use option::Option;
1922

2023
pub mod strconv;
2124

22-
///
2325
/// The base trait for numeric types
24-
///
2526
pub trait Num: Eq + Zero + One
2627
+ Neg<Self>
2728
+ Add<Self,Self>
@@ -188,9 +189,7 @@ pub trait Hyperbolic: Exponential {
188189
#[inline(always)] pub fn acosh<T: Hyperbolic>(value: T) -> T { value.acosh() }
189190
#[inline(always)] pub fn atanh<T: Hyperbolic>(value: T) -> T { value.atanh() }
190191

191-
///
192192
/// Defines constants and methods common to real numbers
193-
///
194193
pub trait Real: Signed
195194
+ Fractional
196195
+ Algebraic
@@ -221,9 +220,7 @@ pub trait Real: Signed
221220
fn to_radians(&self) -> Self;
222221
}
223222

224-
///
225223
/// Methods that are harder to implement and not commonly used.
226-
///
227224
pub trait RealExt: Real {
228225
// FIXME (#5527): usages of `int` should be replaced with an associated
229226
// integer type once these are implemented
@@ -241,9 +238,7 @@ pub trait RealExt: Real {
241238
fn yn(&self, n: int) -> Self;
242239
}
243240

244-
///
245241
/// Collects the bitwise operators under one trait.
246-
///
247242
pub trait Bitwise: Not<Self>
248243
+ BitAnd<Self,Self>
249244
+ BitOr<Self,Self>
@@ -263,11 +258,9 @@ pub trait Bounded {
263258
fn max_value() -> Self;
264259
}
265260

266-
///
267261
/// Specifies the available operations common to all of Rust's core numeric primitives.
268262
/// These may not always make sense from a purely mathematical point of view, but
269263
/// may be useful for systems programming.
270-
///
271264
pub trait Primitive: Num
272265
+ NumCast
273266
+ Bounded
@@ -282,17 +275,13 @@ pub trait Primitive: Num
282275
fn bytes() -> uint;
283276
}
284277

285-
///
286278
/// A collection of traits relevant to primitive signed and unsigned integers
287-
///
288279
pub trait Int: Integer
289280
+ Primitive
290281
+ Bitwise
291282
+ BitCount {}
292283

293-
///
294284
/// Used for representing the classification of floating point numbers
295-
///
296285
#[deriving(Eq)]
297286
pub enum FPCategory {
298287
/// "Not a Number", often obtained by dividing by zero
@@ -307,9 +296,7 @@ pub enum FPCategory {
307296
FPNormal,
308297
}
309298

310-
///
311299
/// Primitive floating point numbers
312-
///
313300
pub trait Float: Real
314301
+ Signed
315302
+ Primitive
@@ -343,7 +330,6 @@ pub trait Float: Real
343330
fn next_after(&self, other: Self) -> Self;
344331
}
345332

346-
///
347333
#[inline(always)] pub fn exp_m1<T: Float>(value: T) -> T { value.exp_m1() }
348334
#[inline(always)] pub fn ln_1p<T: Float>(value: T) -> T { value.ln_1p() }
349335
#[inline(always)] pub fn mul_add<T: Float>(a: T, b: T, c: T) -> T { a.mul_add(b, c) }
@@ -362,9 +348,7 @@ pub fn cast<T:NumCast,U:NumCast>(n: T) -> U {
362348
NumCast::from(n)
363349
}
364350

365-
///
366351
/// An interface for casting between machine scalars
367-
///
368352
pub trait NumCast {
369353
fn from<T:NumCast>(n: T) -> Self;
370354

@@ -436,7 +420,6 @@ pub trait FromStrRadix {
436420
pub fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
437421
}
438422

439-
///
440423
/// Calculates a power to a given radix, optimized for uint `pow` and `radix`.
441424
///
442425
/// Returns `radix^pow` as `T`.

0 commit comments

Comments
 (0)