mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
auto merge of #14291 : Sawyer47/rust/doc-fixes, r=alexcrichton
This commit is contained in:
commit
e8c579e01d
@ -2943,7 +2943,7 @@ See [Break expressions](#break-expressions) and [Continue expressions](#continue
|
||||
break_expr : "break" [ lifetime ];
|
||||
~~~~
|
||||
|
||||
A `break` expression has an optional `label`.
|
||||
A `break` expression has an optional _label_.
|
||||
If the label is absent, then executing a `break` expression immediately terminates the innermost loop enclosing it.
|
||||
It is only permitted in the body of a loop.
|
||||
If the label is present, then `break foo` terminates the loop with label `foo`,
|
||||
@ -2956,7 +2956,7 @@ but must enclose it.
|
||||
continue_expr : "continue" [ lifetime ];
|
||||
~~~~
|
||||
|
||||
A `continue` expression has an optional `label`.
|
||||
A `continue` expression has an optional _label_.
|
||||
If the label is absent,
|
||||
then executing a `continue` expression immediately terminates the current iteration of the innermost loop enclosing it,
|
||||
returning control to the loop *head*.
|
||||
@ -3115,7 +3115,7 @@ let x: List<int> = Cons(10, box Cons(11, box Nil));
|
||||
|
||||
match x {
|
||||
Cons(a, box Cons(b, _)) => {
|
||||
process_pair(a,b);
|
||||
process_pair(a, b);
|
||||
}
|
||||
Cons(10, _) => {
|
||||
process_ten();
|
||||
@ -3329,8 +3329,8 @@ order specified by the tuple type.
|
||||
An example of a tuple type and its use:
|
||||
|
||||
~~~~
|
||||
type Pair<'a> = (int,&'a str);
|
||||
let p: Pair<'static> = (10,"hello");
|
||||
type Pair<'a> = (int, &'a str);
|
||||
let p: Pair<'static> = (10, "hello");
|
||||
let (a, b) = p;
|
||||
assert!(b != "world");
|
||||
~~~~
|
||||
|
@ -2602,7 +2602,7 @@ fn main() {
|
||||
~~~
|
||||
|
||||
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
|
||||
`TotalOrd`, `Encodable` `Decodable`, `Clone`,
|
||||
`TotalOrd`, `Encodable`, `Decodable`, `Clone`,
|
||||
`Hash`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`.
|
||||
|
||||
# Crates and the module system
|
||||
|
@ -15,11 +15,14 @@
|
||||
//! Implementations of the following traits:
|
||||
//!
|
||||
//! * `Not`
|
||||
//! * `BitAnd`
|
||||
//! * `BitOr`
|
||||
//! * `BitXor`
|
||||
//! * `Ord`
|
||||
//! * `TotalOrd`
|
||||
//! * `Eq`
|
||||
//! * `TotalEq`
|
||||
//! * `Default`
|
||||
//! * `Zero`
|
||||
//!
|
||||
//! A `to_bit` conversion function.
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
//! Numeric traits and functions for generic mathematics
|
||||
//!
|
||||
//! These are implemented for the primitive numeric types in `std::{u8, u16,
|
||||
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float}`.
|
||||
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64}`.
|
||||
|
||||
#![allow(missing_doc)]
|
||||
|
||||
@ -97,7 +97,7 @@ pub trait One: Mul<Self, Self> {
|
||||
pub trait Signed: Num + Neg<Self> {
|
||||
/// Computes the absolute value.
|
||||
///
|
||||
/// For float, f32, and f64, `NaN` will be returned if the number is `NaN`.
|
||||
/// For `f32` and `f64`, `NaN` will be returned if the number is `NaN`.
|
||||
fn abs(&self) -> Self;
|
||||
|
||||
/// The positive difference of two numbers.
|
||||
@ -108,15 +108,17 @@ pub trait Signed: Num + Neg<Self> {
|
||||
|
||||
/// Returns the sign of the number.
|
||||
///
|
||||
/// For `float`, `f32`, `f64`:
|
||||
/// * `1.0` if the number is positive, `+0.0` or `INFINITY`
|
||||
/// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
|
||||
/// * `NaN` if the number is `NaN`
|
||||
/// For `f32` and `f64`:
|
||||
///
|
||||
/// * `1.0` if the number is positive, `+0.0` or `INFINITY`
|
||||
/// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
|
||||
/// * `NaN` if the number is `NaN`
|
||||
///
|
||||
/// For `int`:
|
||||
/// * `0` if the number is zero
|
||||
/// * `1` if the number is positive
|
||||
/// * `-1` if the number is negative
|
||||
///
|
||||
/// * `0` if the number is zero
|
||||
/// * `1` if the number is positive
|
||||
/// * `-1` if the number is negative
|
||||
fn signum(&self) -> Self;
|
||||
|
||||
/// Returns true if the number is positive and false if the number is zero or negative.
|
||||
@ -128,7 +130,7 @@ pub trait Signed: Num + Neg<Self> {
|
||||
|
||||
/// Computes the absolute value.
|
||||
///
|
||||
/// For float, f32, and f64, `NaN` will be returned if the number is `NaN`
|
||||
/// For `f32` and `f64`, `NaN` will be returned if the number is `NaN`
|
||||
#[inline(always)]
|
||||
pub fn abs<T: Signed>(value: T) -> T {
|
||||
value.abs()
|
||||
@ -145,15 +147,17 @@ pub fn abs_sub<T: Signed>(x: T, y: T) -> T {
|
||||
|
||||
/// Returns the sign of the number.
|
||||
///
|
||||
/// For float, f32, f64:
|
||||
/// - `1.0` if the number is positive, `+0.0` or `INFINITY`
|
||||
/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
|
||||
/// - `NAN` if the number is `NAN`
|
||||
/// For `f32` and `f64`:
|
||||
///
|
||||
/// * `1.0` if the number is positive, `+0.0` or `INFINITY`
|
||||
/// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
|
||||
/// * `NaN` if the number is `NaN`
|
||||
///
|
||||
/// For int:
|
||||
/// - `0` if the number is zero
|
||||
/// - `1` if the number is positive
|
||||
/// - `-1` if the number is negative
|
||||
///
|
||||
/// * `0` if the number is zero
|
||||
/// * `1` if the number is positive
|
||||
/// * `-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
|
||||
|
@ -11,7 +11,7 @@
|
||||
//! Numeric traits and functions for generic mathematics
|
||||
//!
|
||||
//! These are implemented for the primitive numeric types in `std::{u8, u16,
|
||||
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float}`.
|
||||
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64}`.
|
||||
|
||||
#![allow(missing_doc)]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user