From dbc2e99693eb20da9b9823bc11953835b156802f Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Fri, 26 Apr 2013 09:55:49 +1000 Subject: [PATCH] Use `///` doc-comment form instead of `/** */` --- src/libcore/num/f32.rs | 276 +++++++++++------------ src/libcore/num/f64.rs | 276 +++++++++++------------ src/libcore/num/float.rs | 306 +++++++++++++------------- src/libcore/num/int-template.rs | 268 +++++++++++----------- src/libcore/num/num.rs | 56 ++--- src/libcore/num/uint-template.rs | 7 +- src/libcore/num/uint-template/uint.rs | 128 +++++------ 7 files changed, 658 insertions(+), 659 deletions(-) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index c03761c2322..63e52fab7c9 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -304,13 +304,13 @@ impl Signed for f32 { #[inline(always)] fn abs(&self) -> f32 { abs(*self) } - /** - * # Returns - * - * - `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` - */ + /// + /// # Returns + /// + /// - `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 + /// #[inline(always)] fn signum(&self) -> f32 { if is_NaN(*self) { NaN } else { copysign(1.0, *self) } @@ -509,17 +509,17 @@ impl Real for f32 { fn tanh(&self) -> f32 { tanh(*self) } } -/** - * Section: String Conversions - */ +// +// Section: String Conversions +// -/** - * Converts a float to a string - * - * # Arguments - * - * * num - The float value - */ +/// +/// Converts a float to a string +/// +/// # Arguments +/// +/// * num - The float value +/// #[inline(always)] pub fn to_str(num: f32) -> ~str { let (r, _) = strconv::to_str_common( @@ -527,13 +527,13 @@ pub fn to_str(num: f32) -> ~str { r } -/** - * Converts a float to a string in hexadecimal format - * - * # Arguments - * - * * num - The float value - */ +/// +/// Converts a float to a string in hexadecimal format +/// +/// # Arguments +/// +/// * num - The float value +/// #[inline(always)] pub fn to_str_hex(num: f32) -> ~str { let (r, _) = strconv::to_str_common( @@ -541,20 +541,20 @@ pub fn to_str_hex(num: f32) -> ~str { r } -/** - * Converts a float to a string in a given radix - * - * # Arguments - * - * * num - The float value - * * radix - The base to use - * - * # Failure - * - * Fails if called on a special value like `inf`, `-inf` or `NaN` due to - * possible misinterpretation of the result at higher bases. If those values - * are expected, use `to_str_radix_special()` instead. - */ +/// +/// Converts a float to a string in a given radix +/// +/// # Arguments +/// +/// * num - The float value +/// * radix - The base to use +/// +/// # Failure +/// +/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to +/// possible misinterpretation of the result at higher bases. If those values +/// are expected, use `to_str_radix_special()` instead. +/// #[inline(always)] pub fn to_str_radix(num: f32, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( @@ -564,30 +564,30 @@ pub fn to_str_radix(num: f32, rdx: uint) -> ~str { r } -/** - * Converts a float to a string in a given radix, and a flag indicating - * whether it's a special value - * - * # Arguments - * - * * num - The float value - * * radix - The base to use - */ +/// +/// Converts a float to a string in a given radix, and a flag indicating +/// whether it's a special value +/// +/// # Arguments +/// +/// * num - The float value +/// * radix - The base to use +/// #[inline(always)] pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) { strconv::to_str_common(&num, rdx, true, strconv::SignNeg, strconv::DigAll) } -/** - * Converts a float to a string with exactly the number of - * provided significant digits - * - * # Arguments - * - * * num - The float value - * * digits - The number of significant digits - */ +/// +/// Converts a float to a string with exactly the number of +/// provided significant digits +/// +/// # Arguments +/// +/// * num - The float value +/// * digits - The number of significant digits +/// #[inline(always)] pub fn to_str_exact(num: f32, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( @@ -595,15 +595,15 @@ pub fn to_str_exact(num: f32, dig: uint) -> ~str { r } -/** - * Converts a float to a string with a maximum number of - * significant digits - * - * # Arguments - * - * * num - The float value - * * digits - The number of significant digits - */ +/// +/// Converts a float to a string with a maximum number of +/// significant digits +/// +/// # Arguments +/// +/// * num - The float value +/// * digits - The number of significant digits +/// #[inline(always)] pub fn to_str_digits(num: f32, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( @@ -623,91 +623,91 @@ impl num::ToStrRadix for f32 { } } -/** - * Convert a string in base 10 to a float. - * Accepts a optional decimal exponent. - * - * This function accepts strings such as - * - * * '3.14' - * * '+3.14', equivalent to '3.14' - * * '-3.14' - * * '2.5E10', or equivalently, '2.5e10' - * * '2.5E-10' - * * '.' (understood as 0) - * * '5.' - * * '.5', or, equivalently, '0.5' - * * '+inf', 'inf', '-inf', 'NaN' - * - * Leading and trailing whitespace represent an error. - * - * # Arguments - * - * * num - A string - * - * # Return value - * - * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `num`. - */ +/// +/// Convert a string in base 10 to a float. +/// Accepts a optional decimal exponent. +/// +/// This function accepts strings such as +/// +/// * '3.14' +/// * '+3.14', equivalent to '3.14' +/// * '-3.14' +/// * '2.5E10', or equivalently, '2.5e10' +/// * '2.5E-10' +/// * '.' (understood as 0) +/// * '5.' +/// * '.5', or, equivalently, '0.5' +/// * '+inf', 'inf', '-inf', 'NaN' +/// +/// Leading and trailing whitespace represent an error. +/// +/// # Arguments +/// +/// * num - A string +/// +/// # Return value +/// +/// `none` if the string did not represent a valid number. Otherwise, +/// `Some(n)` where `n` is the floating-point number represented by `num`. +/// #[inline(always)] pub fn from_str(num: &str) -> Option { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) } -/** - * Convert a string in base 16 to a float. - * Accepts a optional binary exponent. - * - * This function accepts strings such as - * - * * 'a4.fe' - * * '+a4.fe', equivalent to 'a4.fe' - * * '-a4.fe' - * * '2b.aP128', or equivalently, '2b.ap128' - * * '2b.aP-128' - * * '.' (understood as 0) - * * 'c.' - * * '.c', or, equivalently, '0.c' - * * '+inf', 'inf', '-inf', 'NaN' - * - * Leading and trailing whitespace represent an error. - * - * # Arguments - * - * * num - A string - * - * # Return value - * - * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `[num]`. - */ +/// +/// Convert a string in base 16 to a float. +/// Accepts a optional binary exponent. +/// +/// This function accepts strings such as +/// +/// * 'a4.fe' +/// * '+a4.fe', equivalent to 'a4.fe' +/// * '-a4.fe' +/// * '2b.aP128', or equivalently, '2b.ap128' +/// * '2b.aP-128' +/// * '.' (understood as 0) +/// * 'c.' +/// * '.c', or, equivalently, '0.c' +/// * '+inf', 'inf', '-inf', 'NaN' +/// +/// Leading and trailing whitespace represent an error. +/// +/// # Arguments +/// +/// * num - A string +/// +/// # Return value +/// +/// `none` if the string did not represent a valid number. Otherwise, +/// `Some(n)` where `n` is the floating-point number represented by `[num]`. +/// #[inline(always)] pub fn from_str_hex(num: &str) -> Option { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) } -/** - * Convert a string in an given base to a float. - * - * Due to possible conflicts, this function does **not** accept - * the special values `inf`, `-inf`, `+inf` and `NaN`, **nor** - * does it recognize exponents of any kind. - * - * Leading and trailing whitespace represent an error. - * - * # Arguments - * - * * num - A string - * * radix - The base to use. Must lie in the range [2 .. 36] - * - * # Return value - * - * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `num`. - */ +/// +/// Convert a string in an given base to a float. +/// +/// Due to possible conflicts, this function does **not** accept +/// the special values `inf`, `-inf`, `+inf` and `NaN`, **nor** +/// does it recognize exponents of any kind. +/// +/// Leading and trailing whitespace represent an error. +/// +/// # Arguments +/// +/// * num - A string +/// * radix - The base to use. Must lie in the range [2 .. 36] +/// +/// # Return value +/// +/// `none` if the string did not represent a valid number. Otherwise, +/// `Some(n)` where `n` is the floating-point number represented by `num`. +/// #[inline(always)] pub fn from_str_radix(num: &str, rdx: uint) -> Option { strconv::from_str_common(num, rdx, true, true, false, diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index ca6416be739..e6013eec243 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -314,13 +314,13 @@ impl Signed for f64 { #[inline(always)] fn abs(&self) -> f64 { abs(*self) } - /** - * # Returns - * - * - `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` - */ + /// + /// # Returns + /// + /// - `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 + /// #[inline(always)] fn signum(&self) -> f64 { if is_NaN(*self) { NaN } else { copysign(1.0, *self) } @@ -549,17 +549,17 @@ impl RealExt for f64 { fn yn(&self, n: int) -> f64 { yn(n as c_int, *self) } } -/** - * Section: String Conversions - */ +// +// Section: String Conversions +// -/** - * Converts a float to a string - * - * # Arguments - * - * * num - The float value - */ +/// +/// Converts a float to a string +/// +/// # Arguments +/// +/// * num - The float value +/// #[inline(always)] pub fn to_str(num: f64) -> ~str { let (r, _) = strconv::to_str_common( @@ -567,13 +567,13 @@ pub fn to_str(num: f64) -> ~str { r } -/** - * Converts a float to a string in hexadecimal format - * - * # Arguments - * - * * num - The float value - */ +/// +/// Converts a float to a string in hexadecimal format +/// +/// # Arguments +/// +/// * num - The float value +/// #[inline(always)] pub fn to_str_hex(num: f64) -> ~str { let (r, _) = strconv::to_str_common( @@ -581,20 +581,20 @@ pub fn to_str_hex(num: f64) -> ~str { r } -/** - * Converts a float to a string in a given radix - * - * # Arguments - * - * * num - The float value - * * radix - The base to use - * - * # Failure - * - * Fails if called on a special value like `inf`, `-inf` or `NaN` due to - * possible misinterpretation of the result at higher bases. If those values - * are expected, use `to_str_radix_special()` instead. - */ +/// +/// Converts a float to a string in a given radix +/// +/// # Arguments +/// +/// * num - The float value +/// * radix - The base to use +/// +/// # Failure +/// +/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to +/// possible misinterpretation of the result at higher bases. If those values +/// are expected, use `to_str_radix_special()` instead. +/// #[inline(always)] pub fn to_str_radix(num: f64, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( @@ -604,30 +604,30 @@ pub fn to_str_radix(num: f64, rdx: uint) -> ~str { r } -/** - * Converts a float to a string in a given radix, and a flag indicating - * whether it's a special value - * - * # Arguments - * - * * num - The float value - * * radix - The base to use - */ +/// +/// Converts a float to a string in a given radix, and a flag indicating +/// whether it's a special value +/// +/// # Arguments +/// +/// * num - The float value +/// * radix - The base to use +/// #[inline(always)] pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) { strconv::to_str_common(&num, rdx, true, strconv::SignNeg, strconv::DigAll) } -/** - * Converts a float to a string with exactly the number of - * provided significant digits - * - * # Arguments - * - * * num - The float value - * * digits - The number of significant digits - */ +/// +/// Converts a float to a string with exactly the number of +/// provided significant digits +/// +/// # Arguments +/// +/// * num - The float value +/// * digits - The number of significant digits +/// #[inline(always)] pub fn to_str_exact(num: f64, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( @@ -635,15 +635,15 @@ pub fn to_str_exact(num: f64, dig: uint) -> ~str { r } -/** - * Converts a float to a string with a maximum number of - * significant digits - * - * # Arguments - * - * * num - The float value - * * digits - The number of significant digits - */ +/// +/// Converts a float to a string with a maximum number of +/// significant digits +/// +/// # Arguments +/// +/// * num - The float value +/// * digits - The number of significant digits +/// #[inline(always)] pub fn to_str_digits(num: f64, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( @@ -663,91 +663,91 @@ impl num::ToStrRadix for f64 { } } -/** - * Convert a string in base 10 to a float. - * Accepts a optional decimal exponent. - * - * This function accepts strings such as - * - * * '3.14' - * * '+3.14', equivalent to '3.14' - * * '-3.14' - * * '2.5E10', or equivalently, '2.5e10' - * * '2.5E-10' - * * '.' (understood as 0) - * * '5.' - * * '.5', or, equivalently, '0.5' - * * '+inf', 'inf', '-inf', 'NaN' - * - * Leading and trailing whitespace represent an error. - * - * # Arguments - * - * * num - A string - * - * # Return value - * - * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `num`. - */ +/// +/// Convert a string in base 10 to a float. +/// Accepts a optional decimal exponent. +/// +/// This function accepts strings such as +/// +/// * '3.14' +/// * '+3.14', equivalent to '3.14' +/// * '-3.14' +/// * '2.5E10', or equivalently, '2.5e10' +/// * '2.5E-10' +/// * '.' (understood as 0) +/// * '5.' +/// * '.5', or, equivalently, '0.5' +/// * '+inf', 'inf', '-inf', 'NaN' +/// +/// Leading and trailing whitespace represent an error. +/// +/// # Arguments +/// +/// * num - A string +/// +/// # Return value +/// +/// `none` if the string did not represent a valid number. Otherwise, +/// `Some(n)` where `n` is the floating-point number represented by `num`. +/// #[inline(always)] pub fn from_str(num: &str) -> Option { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) } -/** - * Convert a string in base 16 to a float. - * Accepts a optional binary exponent. - * - * This function accepts strings such as - * - * * 'a4.fe' - * * '+a4.fe', equivalent to 'a4.fe' - * * '-a4.fe' - * * '2b.aP128', or equivalently, '2b.ap128' - * * '2b.aP-128' - * * '.' (understood as 0) - * * 'c.' - * * '.c', or, equivalently, '0.c' - * * '+inf', 'inf', '-inf', 'NaN' - * - * Leading and trailing whitespace represent an error. - * - * # Arguments - * - * * num - A string - * - * # Return value - * - * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `[num]`. - */ +/// +/// Convert a string in base 16 to a float. +/// Accepts a optional binary exponent. +/// +/// This function accepts strings such as +/// +/// * 'a4.fe' +/// * '+a4.fe', equivalent to 'a4.fe' +/// * '-a4.fe' +/// * '2b.aP128', or equivalently, '2b.ap128' +/// * '2b.aP-128' +/// * '.' (understood as 0) +/// * 'c.' +/// * '.c', or, equivalently, '0.c' +/// * '+inf', 'inf', '-inf', 'NaN' +/// +/// Leading and trailing whitespace represent an error. +/// +/// # Arguments +/// +/// * num - A string +/// +/// # Return value +/// +/// `none` if the string did not represent a valid number. Otherwise, +/// `Some(n)` where `n` is the floating-point number represented by `[num]`. +/// #[inline(always)] pub fn from_str_hex(num: &str) -> Option { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) } -/** - * Convert a string in an given base to a float. - * - * Due to possible conflicts, this function does **not** accept - * the special values `inf`, `-inf`, `+inf` and `NaN`, **nor** - * does it recognize exponents of any kind. - * - * Leading and trailing whitespace represent an error. - * - * # Arguments - * - * * num - A string - * * radix - The base to use. Must lie in the range [2 .. 36] - * - * # Return value - * - * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `num`. - */ +/// +/// Convert a string in an given base to a float. +/// +/// Due to possible conflicts, this function does **not** accept +/// the special values `inf`, `-inf`, `+inf` and `NaN`, **nor** +/// does it recognize exponents of any kind. +/// +/// Leading and trailing whitespace represent an error. +/// +/// # Arguments +/// +/// * num - A string +/// * radix - The base to use. Must lie in the range [2 .. 36] +/// +/// # Return value +/// +/// `none` if the string did not represent a valid number. Otherwise, +/// `Some(n)` where `n` is the floating-point number represented by `num`. +/// #[inline(always)] pub fn from_str_radix(num: &str, rdx: uint) -> Option { strconv::from_str_common(num, rdx, true, true, false, diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index 248bc2a4d56..d5f22e6b056 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -84,17 +84,17 @@ pub mod consts { pub static ln_10: float = 2.30258509299404568401799145468436421; } -/* - * Section: String Conversions - */ +// +// Section: String Conversions +// -/** - * Converts a float to a string - * - * # Arguments - * - * * num - The float value - */ +/// +/// Converts a float to a string +/// +/// # Arguments +/// +/// * num - The float value +/// #[inline(always)] pub fn to_str(num: float) -> ~str { let (r, _) = strconv::to_str_common( @@ -102,13 +102,13 @@ pub fn to_str(num: float) -> ~str { r } -/** - * Converts a float to a string in hexadecimal format - * - * # Arguments - * - * * num - The float value - */ +/// +/// Converts a float to a string in hexadecimal format +/// +/// # Arguments +/// +/// * num - The float value +/// #[inline(always)] pub fn to_str_hex(num: float) -> ~str { let (r, _) = strconv::to_str_common( @@ -116,20 +116,20 @@ pub fn to_str_hex(num: float) -> ~str { r } -/** - * Converts a float to a string in a given radix - * - * # Arguments - * - * * num - The float value - * * radix - The base to use - * - * # Failure - * - * Fails if called on a special value like `inf`, `-inf` or `NaN` due to - * possible misinterpretation of the result at higher bases. If those values - * are expected, use `to_str_radix_special()` instead. - */ +/// +/// Converts a float to a string in a given radix +/// +/// # Arguments +/// +/// * num - The float value +/// * radix - The base to use +/// +/// # Failure +/// +/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to +/// possible misinterpretation of the result at higher bases. If those values +/// are expected, use `to_str_radix_special()` instead. +/// #[inline(always)] pub fn to_str_radix(num: float, radix: uint) -> ~str { let (r, special) = strconv::to_str_common( @@ -139,30 +139,30 @@ pub fn to_str_radix(num: float, radix: uint) -> ~str { r } -/** - * Converts a float to a string in a given radix, and a flag indicating - * whether it's a special value - * - * # Arguments - * - * * num - The float value - * * radix - The base to use - */ +/// +/// Converts a float to a string in a given radix, and a flag indicating +/// whether it's a special value +/// +/// # Arguments +/// +/// * num - The float value +/// * radix - The base to use +/// #[inline(always)] pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { strconv::to_str_common(&num, radix, true, strconv::SignNeg, strconv::DigAll) } -/** - * Converts a float to a string with exactly the number of - * provided significant digits - * - * # Arguments - * - * * num - The float value - * * digits - The number of significant digits - */ +/// +/// Converts a float to a string with exactly the number of +/// provided significant digits +/// +/// # Arguments +/// +/// * num - The float value +/// * digits - The number of significant digits +/// #[inline(always)] pub fn to_str_exact(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( @@ -170,15 +170,15 @@ pub fn to_str_exact(num: float, digits: uint) -> ~str { r } -/** - * Converts a float to a string with a maximum number of - * significant digits - * - * # Arguments - * - * * num - The float value - * * digits - The number of significant digits - */ +/// +/// Converts a float to a string with a maximum number of +/// significant digits +/// +/// # Arguments +/// +/// * num - The float value +/// * digits - The number of significant digits +/// #[inline(always)] pub fn to_str_digits(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( @@ -198,91 +198,91 @@ impl num::ToStrRadix for float { } } -/** - * Convert a string in base 10 to a float. - * Accepts a optional decimal exponent. - * - * This function accepts strings such as - * - * * '3.14' - * * '+3.14', equivalent to '3.14' - * * '-3.14' - * * '2.5E10', or equivalently, '2.5e10' - * * '2.5E-10' - * * '.' (understood as 0) - * * '5.' - * * '.5', or, equivalently, '0.5' - * * '+inf', 'inf', '-inf', 'NaN' - * - * Leading and trailing whitespace represent an error. - * - * # Arguments - * - * * num - A string - * - * # Return value - * - * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `num`. - */ +/// +/// Convert a string in base 10 to a float. +/// Accepts a optional decimal exponent. +/// +/// This function accepts strings such as +/// +/// * '3.14' +/// * '+3.14', equivalent to '3.14' +/// * '-3.14' +/// * '2.5E10', or equivalently, '2.5e10' +/// * '2.5E-10' +/// * '.' (understood as 0) +/// * '5.' +/// * '.5', or, equivalently, '0.5' +/// * '+inf', 'inf', '-inf', 'NaN' +/// +/// Leading and trailing whitespace represent an error. +/// +/// # Arguments +/// +/// * num - A string +/// +/// # Return value +/// +/// `none` if the string did not represent a valid number. Otherwise, +/// `Some(n)` where `n` is the floating-point number represented by `num`. +/// #[inline(always)] pub fn from_str(num: &str) -> Option { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) } -/** - * Convert a string in base 16 to a float. - * Accepts a optional binary exponent. - * - * This function accepts strings such as - * - * * 'a4.fe' - * * '+a4.fe', equivalent to 'a4.fe' - * * '-a4.fe' - * * '2b.aP128', or equivalently, '2b.ap128' - * * '2b.aP-128' - * * '.' (understood as 0) - * * 'c.' - * * '.c', or, equivalently, '0.c' - * * '+inf', 'inf', '-inf', 'NaN' - * - * Leading and trailing whitespace represent an error. - * - * # Arguments - * - * * num - A string - * - * # Return value - * - * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `[num]`. - */ +/// +/// Convert a string in base 16 to a float. +/// Accepts a optional binary exponent. +/// +/// This function accepts strings such as +/// +/// * 'a4.fe' +/// * '+a4.fe', equivalent to 'a4.fe' +/// * '-a4.fe' +/// * '2b.aP128', or equivalently, '2b.ap128' +/// * '2b.aP-128' +/// * '.' (understood as 0) +/// * 'c.' +/// * '.c', or, equivalently, '0.c' +/// * '+inf', 'inf', '-inf', 'NaN' +/// +/// Leading and trailing whitespace represent an error. +/// +/// # Arguments +/// +/// * num - A string +/// +/// # Return value +/// +/// `none` if the string did not represent a valid number. Otherwise, +/// `Some(n)` where `n` is the floating-point number represented by `[num]`. +/// #[inline(always)] pub fn from_str_hex(num: &str) -> Option { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) } -/** - * Convert a string in an given base to a float. - * - * Due to possible conflicts, this function does **not** accept - * the special values `inf`, `-inf`, `+inf` and `NaN`, **nor** - * does it recognize exponents of any kind. - * - * Leading and trailing whitespace represent an error. - * - * # Arguments - * - * * num - A string - * * radix - The base to use. Must lie in the range [2 .. 36] - * - * # Return value - * - * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `num`. - */ +/// +/// Convert a string in an given base to a float. +/// +/// Due to possible conflicts, this function does **not** accept +/// the special values `inf`, `-inf`, `+inf` and `NaN`, **nor** +/// does it recognize exponents of any kind. +/// +/// Leading and trailing whitespace represent an error. +/// +/// # Arguments +/// +/// * num - A string +/// * radix - The base to use. Must lie in the range [2 .. 36] +/// +/// # Return value +/// +/// `none` if the string did not represent a valid number. Otherwise, +/// `Some(n)` where `n` is the floating-point number represented by `num`. +/// #[inline(always)] pub fn from_str_radix(num: &str, radix: uint) -> Option { strconv::from_str_common(num, radix, true, true, false, @@ -301,22 +301,22 @@ impl num::FromStrRadix for float { } } -/** - * Section: Arithmetics - */ +// +// Section: Arithmetics +// -/** - * Compute the exponentiation of an integer by another integer as a float - * - * # Arguments - * - * * x - The base - * * pow - The exponent - * - * # Return value - * - * `NaN` if both `x` and `pow` are `0u`, otherwise `x^pow` - */ +/// +/// Compute the exponentiation of an integer by another integer as a float +/// +/// # Arguments +/// +/// * x - The base +/// * pow - The exponent +/// +/// # Return value +/// +/// `NaN` if both `x` and `pow` are `0u`, otherwise `x^pow` +/// pub fn pow_with_uint(base: uint, pow: uint) -> float { if base == 0u { if pow == 0u { @@ -668,13 +668,13 @@ impl Signed for float { #[inline(always)] fn abs(&self) -> float { abs(*self) } - /** - * # Returns - * - * - `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 - */ + /// + /// # Returns + /// + /// - `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 + /// #[inline(always)] fn signum(&self) -> float { if is_NaN(*self) { NaN } else { f64::copysign(1.0, *self as f64) as float } diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index b53bf876f77..75d170118e6 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -32,26 +32,26 @@ pub fn mul(x: T, y: T) -> T { x * y } #[inline(always)] pub fn quot(x: T, y: T) -> T { x / y } -/** - * Returns the remainder of y / x. - * - * # Examples - * ~~~ - * assert!(int::rem(5 / 2) == 1); - * ~~~ - * - * When faced with negative numbers, the result copies the sign of the - * dividend. - * - * ~~~ - * assert!(int::rem(2 / -3) == 2); - * ~~~ - * - * ~~~ - * assert!(int::rem(-2 / 3) == -2); - * ~~~ - * - */ +/// +/// Returns the remainder of y / x. +/// +/// # Examples +/// ~~~ +/// assert!(int::rem(5 / 2) == 1); +/// ~~~ +/// +/// When faced with negative numbers, the result copies the sign of the +/// dividend. +/// +/// ~~~ +/// assert!(int::rem(2 / -3) == 2); +/// ~~~ +/// +/// ~~~ +/// assert!(int::rem(-2 / 3) == -2); +/// ~~~ +/// +/// #[inline(always)] pub fn rem(x: T, y: T) -> T { x % y } @@ -68,23 +68,23 @@ pub fn ge(x: T, y: T) -> bool { x >= y } #[inline(always)] pub fn gt(x: T, y: T) -> bool { x > y } -/** - * Iterate over the range [`lo`..`hi`) - * - * # Arguments - * - * * `lo` - lower bound, inclusive - * * `hi` - higher bound, exclusive - * - * # Examples - * ~~~ - * let mut sum = 0; - * for int::range(1, 5) |i| { - * sum += i; - * } - * assert!(sum == 10); - * ~~~ - */ +/// +/// Iterate over the range [`lo`..`hi`) +/// +/// # Arguments +/// +/// * `lo` - lower bound, inclusive +/// * `hi` - higher bound, exclusive +/// +/// # Examples +/// ~~~ +/// let mut sum = 0; +/// for int::range(1, 5) |i| { +/// sum += i; +/// } +/// assert!(sum == 10); +/// ~~~ +/// #[inline(always)] /// Iterate over the range [`start`,`start`+`step`..`stop`) pub fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) { @@ -190,24 +190,24 @@ impl Div for T { } #[cfg(not(stage0),notest)] impl Quot for T { - /** - * Returns the integer quotient, truncated towards 0. As this behaviour reflects - * the underlying machine implementation it is more efficient than `Natural::div`. - * - * # Examples - * - * ~~~ - * assert!( 8 / 3 == 2); - * assert!( 8 / -3 == -2); - * assert!(-8 / 3 == -2); - * assert!(-8 / -3 == 2); + /// + /// Returns the integer quotient, truncated towards 0. As this behaviour reflects + /// the underlying machine implementation it is more efficient than `Natural::div`. + /// + /// # Examples + /// + /// ~~~ + /// assert!( 8 / 3 == 2); + /// assert!( 8 / -3 == -2); + /// assert!(-8 / 3 == -2); + /// assert!(-8 / -3 == 2); - * assert!( 1 / 2 == 0); - * assert!( 1 / -2 == 0); - * assert!(-1 / 2 == 0); - * assert!(-1 / -2 == 0); - * ~~~ - */ + /// assert!( 1 / 2 == 0); + /// assert!( 1 / -2 == 0); + /// assert!(-1 / 2 == 0); + /// assert!(-1 / -2 == 0); + /// ~~~ + /// #[inline(always)] fn quot(&self, other: &T) -> T { *self / *other } } @@ -219,27 +219,27 @@ impl Modulo for T { } #[cfg(not(stage0),notest)] impl Rem for T { - /** - * Returns the integer remainder after division, satisfying: - * - * ~~~ - * assert!((n / d) * d + (n % d) == n) - * ~~~ - * - * # Examples - * - * ~~~ - * assert!( 8 % 3 == 2); - * assert!( 8 % -3 == 2); - * assert!(-8 % 3 == -2); - * assert!(-8 % -3 == -2); + /// + /// Returns the integer remainder after division, satisfying: + /// + /// ~~~ + /// assert!((n / d) * d + (n % d) == n) + /// ~~~ + /// + /// # Examples + /// + /// ~~~ + /// assert!( 8 % 3 == 2); + /// assert!( 8 % -3 == 2); + /// assert!(-8 % 3 == -2); + /// assert!(-8 % -3 == -2); - * assert!( 1 % 2 == 1); - * assert!( 1 % -2 == 1); - * assert!(-1 % 2 == -1); - * assert!(-1 % -2 == -1); - * ~~~ - */ + /// assert!( 1 % 2 == 1); + /// assert!( 1 % -2 == 1); + /// assert!(-1 % 2 == -1); + /// assert!(-1 % -2 == -1); + /// ~~~ + /// #[inline(always)] fn rem(&self, other: &T) -> T { *self % *other } } @@ -257,13 +257,13 @@ impl Signed for T { if self.is_negative() { -*self } else { *self } } - /** - * # Returns - * - * - `0` if the number is zero - * - `1` if the number is positive - * - `-1` if the number is negative - */ + /// + /// # Returns + /// + /// - `0` if the number is zero + /// - `1` if the number is positive + /// - `-1` if the number is negative + /// #[inline(always)] fn signum(&self) -> T { match *self { @@ -283,23 +283,23 @@ impl Signed for T { } impl Integer for T { - /** - * Floored integer division - * - * # Examples - * - * ~~~ - * assert!(( 8).div( 3) == 2); - * assert!(( 8).div(-3) == -3); - * assert!((-8).div( 3) == -3); - * assert!((-8).div(-3) == 2); - * - * assert!(( 1).div( 2) == 0); - * assert!(( 1).div(-2) == -1); - * assert!((-1).div( 2) == -1); - * assert!((-1).div(-2) == 0); - * ~~~ - */ + /// + /// Floored integer division + /// + /// # Examples + /// + /// ~~~ + /// assert!(( 8).div( 3) == 2); + /// assert!(( 8).div(-3) == -3); + /// assert!((-8).div( 3) == -3); + /// assert!((-8).div(-3) == 2); + /// + /// assert!(( 1).div( 2) == 0); + /// assert!(( 1).div(-2) == -1); + /// assert!((-1).div( 2) == -1); + /// assert!((-1).div(-2) == 0); + /// ~~~ + /// #[inline(always)] fn div(&self, other: &T) -> T { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, @@ -311,27 +311,27 @@ impl Integer for T { } } - /** - * Integer modulo, satisfying: - * - * ~~~ - * assert!(n.div(d) * d + n.modulo(d) == n) - * ~~~ - * - * # Examples - * - * ~~~ - * assert!(( 8).modulo( 3) == 2); - * assert!(( 8).modulo(-3) == -1); - * assert!((-8).modulo( 3) == 1); - * assert!((-8).modulo(-3) == -2); - * - * assert!(( 1).modulo( 2) == 1); - * assert!(( 1).modulo(-2) == -1); - * assert!((-1).modulo( 2) == 1); - * assert!((-1).modulo(-2) == -1); - * ~~~ - */ + /// + /// Integer modulo, satisfying: + /// + /// ~~~ + /// assert!(n.div(d) * d + n.modulo(d) == n) + /// ~~~ + /// + /// # Examples + /// + /// ~~~ + /// assert!(( 8).modulo( 3) == 2); + /// assert!(( 8).modulo(-3) == -1); + /// assert!((-8).modulo( 3) == 1); + /// assert!((-8).modulo(-3) == -2); + /// + /// assert!(( 1).modulo( 2) == 1); + /// assert!(( 1).modulo(-2) == -1); + /// assert!((-1).modulo( 2) == 1); + /// assert!((-1).modulo(-2) == -1); + /// ~~~ + /// #[inline(always)] fn modulo(&self, other: &T) -> T { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, @@ -361,11 +361,11 @@ impl Integer for T { (*self / *other, *self % *other) } - /** - * Calculates the Greatest Common Divisor (GCD) of the number and `other` - * - * The result is always positive - */ + /// + /// Calculates the Greatest Common Divisor (GCD) of the number and `other` + /// + /// The result is always positive + /// #[inline(always)] fn gcd(&self, other: &T) -> T { // Use Euclid's algorithm @@ -378,9 +378,9 @@ impl Integer for T { n.abs() } - /** - * Calculates the Lowest Common Multiple (LCM) of the number and `other` - */ + /// + /// Calculates the Lowest Common Multiple (LCM) of the number and `other` + /// #[inline(always)] fn lcm(&self, other: &T) -> T { ((*self * *other) / self.gcd(other)).abs() // should not have to recaluculate abs @@ -545,13 +545,13 @@ mod tests { assert!((-1 as T).is_negative()); } - /** - * Checks that the division rule holds for: - * - * - `n`: numerator (dividend) - * - `d`: denominator (divisor) - * - `qr`: quotient and remainder - */ + /// + /// Checks that the division rule holds for: + /// + /// - `n`: numerator (dividend) + /// - `d`: denominator (divisor) + /// - `qr`: quotient and remainder + /// #[cfg(test)] fn test_division_rule(nd: (T,T), qr: (T,T)) { let (n,d) = nd, diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index 19d5340527d..5797d86e6ec 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -153,7 +153,9 @@ pub trait Real: Signed fn tanh(&self) -> Self; } +/// /// Methods that are harder to implement and not commonly used. +/// pub trait RealExt: Real { // FIXME (#5527): usages of `int` should be replaced with an associated // integer type once these are implemented @@ -171,24 +173,24 @@ pub trait RealExt: Real { fn yn(&self, n: int) -> Self; } -/** - * Cast from one machine scalar to another - * - * # Example - * - * ~~~ - * let twenty: f32 = num::cast(0x14); - * assert_eq!(twenty, 20f32); - * ~~~ - */ +/// +/// Cast from one machine scalar to another +/// +/// # Example +/// +/// ~~~ +/// let twenty: f32 = num::cast(0x14); +/// assert_eq!(twenty, 20f32); +/// ~~~ +/// #[inline(always)] pub fn cast(n: T) -> U { NumCast::from(n) } -/** - * An interface for casting between machine scalars - */ +/// +/// An interface for casting between machine scalars +/// pub trait NumCast { fn from(n: T) -> Self; @@ -260,21 +262,19 @@ pub trait FromStrRadix { pub fn from_str_radix(str: &str, radix: uint) -> Option; } -// Generic math functions: - -/** - * Calculates a power to a given radix, optimized for uint `pow` and `radix`. - * - * Returns `radix^pow` as `T`. - * - * Note: - * Also returns `1` for `0^0`, despite that technically being an - * undefined number. The reason for this is twofold: - * - If code written to use this function cares about that special case, it's - * probably going to catch it before making the call. - * - If code written to use this function doesn't care about it, it's - * probably assuming that `x^0` always equals `1`. - */ +/// +/// Calculates a power to a given radix, optimized for uint `pow` and `radix`. +/// +/// Returns `radix^pow` as `T`. +/// +/// Note: +/// Also returns `1` for `0^0`, despite that technically being an +/// undefined number. The reason for this is twofold: +/// - If code written to use this function cares about that special case, it's +/// probably going to catch it before making the call. +/// - If code written to use this function doesn't care about it, it's +/// probably assuming that `x^0` always equals `1`. +/// pub fn pow_with_uint+Mul>( radix: uint, pow: uint) -> T { let _0: T = Zero::zero(); diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 803d034c919..ed0a5aa3876 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -49,10 +49,9 @@ pub fn ge(x: T, y: T) -> bool { x >= y } pub fn gt(x: T, y: T) -> bool { x > y } #[inline(always)] -/** - * Iterate over the range [`start`,`start`+`step`..`stop`) - * - */ +/// +/// Iterate over the range [`start`,`start`+`step`..`stop`) +/// pub fn range_step(start: T, stop: T, step: T_SIGNED, diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index efcf68aba31..5eaa27fb7a0 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -31,74 +31,74 @@ pub mod inst { #[cfg(target_arch = "x86_64")] pub static bits: uint = 64; - /** - * Divide two numbers, return the result, rounded up. - * - * # Arguments - * - * * x - an integer - * * y - an integer distinct from 0u - * - * # Return value - * - * The smallest integer `q` such that `x/y <= q`. - */ + /// + /// Divide two numbers, return the result, rounded up. + /// + /// # Arguments + /// + /// * x - an integer + /// * y - an integer distinct from 0u + /// + /// # Return value + /// + /// The smallest integer `q` such that `x/y <= q`. + /// pub fn div_ceil(x: uint, y: uint) -> uint { let div = x / y; if x % y == 0u { div } else { div + 1u } } - /** - * Divide two numbers, return the result, rounded to the closest integer. - * - * # Arguments - * - * * x - an integer - * * y - an integer distinct from 0u - * - * # Return value - * - * The integer `q` closest to `x/y`. - */ + /// + /// Divide two numbers, return the result, rounded to the closest integer. + /// + /// # Arguments + /// + /// * x - an integer + /// * y - an integer distinct from 0u + /// + /// # Return value + /// + /// The integer `q` closest to `x/y`. + /// pub fn div_round(x: uint, y: uint) -> uint { let div = x / y; if x % y * 2u < y { div } else { div + 1u } } - /** - * Divide two numbers, return the result, rounded down. - * - * Note: This is the same function as `div`. - * - * # Arguments - * - * * x - an integer - * * y - an integer distinct from 0u - * - * # Return value - * - * The smallest integer `q` such that `x/y <= q`. This - * is either `x/y` or `x/y + 1`. - */ + /// + /// Divide two numbers, return the result, rounded down. + /// + /// Note: This is the same function as `div`. + /// + /// # Arguments + /// + /// * x - an integer + /// * y - an integer distinct from 0u + /// + /// # Return value + /// + /// The smallest integer `q` such that `x/y <= q`. This + /// is either `x/y` or `x/y + 1`. + /// pub fn div_floor(x: uint, y: uint) -> uint { return x / y; } - /** - * Iterate over the range [`lo`..`hi`), or stop when requested - * - * # Arguments - * - * * lo - The integer at which to start the loop (included) - * * hi - The integer at which to stop the loop (excluded) - * * it - A block to execute with each consecutive integer of the range. - * Return `true` to continue, `false` to stop. - * - * # Return value - * - * `true` If execution proceeded correctly, `false` if it was interrupted, - * that is if `it` returned `false` at any point. - */ + /// + /// Iterate over the range [`lo`..`hi`), or stop when requested + /// + /// # Arguments + /// + /// * lo - The integer at which to start the loop (included) + /// * hi - The integer at which to stop the loop (excluded) + /// * it - A block to execute with each consecutive integer of the range. + /// Return `true` to continue, `false` to stop. + /// + /// # Return value + /// + /// `true` If execution proceeded correctly, `false` if it was interrupted, + /// that is if `it` returned `false` at any point. + /// pub fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool { let mut i = lo; while i < hi { @@ -110,16 +110,16 @@ pub mod inst { impl iter::Times for uint { #[inline(always)] - /** - * A convenience form for basic iteration. Given a uint `x`, - * `for x.times { ... }` executes the given block x times. - * - * Equivalent to `for uint::range(0, x) |_| { ... }`. - * - * Not defined on all integer types to permit unambiguous - * use with integer literals of inferred integer-type as - * the self-value (eg. `for 100.times { ... }`). - */ + /// + /// A convenience form for basic iteration. Given a uint `x`, + /// `for x.times { ... }` executes the given block x times. + /// + /// Equivalent to `for uint::range(0, x) |_| { ... }`. + /// + /// Not defined on all integer types to permit unambiguous + /// use with integer literals of inferred integer-type as + /// the self-value (eg. `for 100.times { ... }`). + /// fn times(&self, it: &fn() -> bool) { let mut i = *self; while i > 0 {