diff --git a/src/cast.rs b/src/cast.rs index 125e2e38..b0918096 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -102,7 +102,7 @@ pub trait ToPrimitive { } /// Converts the value of `self` to an `f32`. Overflows may map to positive - /// or negative inifinity, otherwise `None` is returned if the value cannot + /// or negative infinity, otherwise `None` is returned if the value cannot /// be represented by an `f32`. #[inline] fn to_f32(&self) -> Option { @@ -110,7 +110,7 @@ pub trait ToPrimitive { } /// Converts the value of `self` to an `f64`. Overflows may map to positive - /// or negative inifinity, otherwise `None` is returned if the value cannot + /// or negative infinity, otherwise `None` is returned if the value cannot /// be represented by an `f64`. /// /// The default implementation tries to convert through `to_i64()`, and diff --git a/src/float.rs b/src/float.rs index 87f8387b..79e52844 100644 --- a/src/float.rs +++ b/src/float.rs @@ -8,7 +8,7 @@ use crate::{Num, NumCast, ToPrimitive}; /// Generic trait for floating point numbers that works with `no_std`. /// -/// This trait implements a subset of the `Float` trait. +/// This trait implements a subset of the [`Float`] trait. pub trait FloatCore: Num + NumCast + Neg + PartialOrd + Copy { /// Returns positive infinity. /// @@ -267,9 +267,9 @@ pub trait FloatCore: Num + NumCast + Neg + PartialOrd + Copy { self.classify() == FpCategory::Subnormal } - /// Returns the floating point category of the number. If only one property - /// is going to be tested, it is generally faster to use the specific - /// predicate instead. + /// Returns the [floating point category](FpCategory) of the number. If + /// only one property is going to be tested, it is generally faster to + /// use the specific predicate instead. /// /// # Examples /// @@ -463,8 +463,8 @@ pub trait FloatCore: Num + NumCast + Neg + PartialOrd + Copy { } } - /// Computes the absolute value of `self`. Returns `FloatCore::nan()` if the - /// number is `FloatCore::nan()`. + /// Computes the absolute value of `self`. Returns [`FloatCore::nan()`] if the + /// number is [`FloatCore::nan()`]. /// /// # Examples /// @@ -496,9 +496,9 @@ pub trait FloatCore: Num + NumCast + Neg + PartialOrd + Copy { /// Returns a number that represents the sign of `self`. /// - /// - `1.0` if the number is positive, `+0.0` or `FloatCore::infinity()` - /// - `-1.0` if the number is negative, `-0.0` or `FloatCore::neg_infinity()` - /// - `FloatCore::nan()` if the number is `FloatCore::nan()` + /// - `1.0` if the number is positive, `+0.0` or [`FloatCore::infinity()`] + /// - `-1.0` if the number is negative, `-0.0` or [`FloatCore::neg_infinity()`] + /// - [`FloatCore::nan()`] if the number is [`FloatCore::nan()`] /// /// # Examples /// @@ -529,7 +529,7 @@ pub trait FloatCore: Num + NumCast + Neg + PartialOrd + Copy { } /// Returns `true` if `self` is positive, including `+0.0` and - /// `FloatCore::infinity()`, and `FloatCore::nan()`. + /// [`FloatCore::infinity()`], and [`FloatCore::nan()`]. /// /// # Examples /// @@ -556,7 +556,7 @@ pub trait FloatCore: Num + NumCast + Neg + PartialOrd + Copy { } /// Returns `true` if `self` is negative, including `-0.0` and - /// `FloatCore::neg_infinity()`, and `-FloatCore::nan()`. + /// [`FloatCore::neg_infinity()`], and [`-FloatCore::nan()`](FloatCore::nan). /// /// # Examples /// @@ -676,7 +676,7 @@ pub trait FloatCore: Num + NumCast + Neg + PartialOrd + Copy { /// Raise a number to an integer power. /// - /// Using this function is generally faster than using `powf` + /// Using this function is generally faster than using `powf`. /// /// # Examples /// @@ -1010,7 +1010,7 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg { /// ``` fn max_value() -> Self; - /// Returns `true` if this value is `NaN` and false otherwise. + /// Returns `true` if this value is `NaN` and `false` otherwise. /// /// ``` /// use num_traits::Float; @@ -1025,7 +1025,7 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg { fn is_nan(self) -> bool; /// Returns `true` if this value is positive infinity or negative infinity and - /// false otherwise. + /// `false` otherwise. /// /// ``` /// use num_traits::Float; diff --git a/src/int.rs b/src/int.rs index e3ca72c0..85f4494a 100644 --- a/src/int.rs +++ b/src/int.rs @@ -16,9 +16,9 @@ use crate::{Num, NumCast}; /// and behave like builtin integers. Furthermore, the types are expected to expose the integer /// value in binary representation and support bitwise operators. The standard bitwise operations /// (e.g., bitwise-and, bitwise-or, right-shift, left-shift) are inherited and the trait extends -/// these with introspective queries (e.g., `PrimInt::count_ones()`, `PrimInt::leading_zeros()`), -/// bitwise combinators (e.g., `PrimInt::rotate_left()`), and endianness converters (e.g., -/// `PrimInt::to_be()`). +/// these with introspective queries (e.g., [`PrimInt::count_ones()`], [`PrimInt::leading_zeros()`]), +/// bitwise combinators (e.g., [`PrimInt::rotate_left()`]), and endianness converters (e.g., +/// [`PrimInt::to_be()`]). /// /// All `PrimInt` types are expected to be fixed-width binary integers. The width can be queried /// via `T::zero().count_zeros()`. The trait currently lacks a way to query the width at @@ -171,7 +171,7 @@ pub trait PrimInt: /// Shifts the bits to the left by a specified amount, `n`, filling /// zeros in the least significant bits. /// - /// This is bitwise equivalent to signed `Shl`. + /// This is bitwise equivalent to signed [`Shl`]. /// /// # Examples /// @@ -188,7 +188,7 @@ pub trait PrimInt: /// Shifts the bits to the right by a specified amount, `n`, copying /// the "sign bit" in the most significant bits even for unsigned types. /// - /// This is bitwise equivalent to signed `Shr`. + /// This is bitwise equivalent to signed [`Shr`]. /// /// # Examples /// @@ -205,7 +205,7 @@ pub trait PrimInt: /// Shifts the bits to the left by a specified amount, `n`, filling /// zeros in the least significant bits. /// - /// This is bitwise equivalent to unsigned `Shl`. + /// This is bitwise equivalent to unsigned [`Shl`]. /// /// # Examples /// @@ -222,7 +222,7 @@ pub trait PrimInt: /// Shifts the bits to the right by a specified amount, `n`, filling /// zeros in the most significant bits. /// - /// This is bitwise equivalent to unsigned `Shr`. + /// This is bitwise equivalent to unsigned [`Shr`]. /// /// # Examples /// diff --git a/src/real.rs b/src/real.rs index d4feee0f..e4b4a115 100644 --- a/src/real.rs +++ b/src/real.rs @@ -135,8 +135,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg { /// ``` fn fract(self) -> Self; - /// Computes the absolute value of `self`. Returns `Float::nan()` if the - /// number is `Float::nan()`. + /// Computes the absolute value of `self`. Returns [`Float::nan()`] if the + /// number is [`Float::nan()`]. /// /// ``` /// use num_traits::real::Real; @@ -157,9 +157,9 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg { /// Returns a number that represents the sign of `self`. /// - /// - `1.0` if the number is positive, `+0.0` or `Float::infinity()` - /// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()` - /// - `Float::nan()` if the number is `Float::nan()` + /// - `1.0` if the number is positive, `+0.0` or [`Float::infinity()`] + /// - `-1.0` if the number is negative, `-0.0` or [`Float::neg_infinity()`] + /// - `Float::nan()` if the number is [`Float::nan()`] /// /// ``` /// use num_traits::real::Real; @@ -175,7 +175,7 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg { fn signum(self) -> Self; /// Returns `true` if `self` is positive, including `+0.0`, - /// `Float::infinity()`, and with newer versions of Rust `f64::NAN`. + /// [`Float::infinity()`], and with newer versions of Rust [`f64::NAN`]. /// /// ``` /// use num_traits::real::Real; @@ -193,7 +193,7 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg { fn is_sign_positive(self) -> bool; /// Returns `true` if `self` is negative, including `-0.0`, - /// `Float::neg_infinity()`, and with newer versions of Rust `-f64::NAN`. + /// [`Float::neg_infinity()`], and with newer versions of Rust [`-f64::NAN`](f64::NAN). /// /// ``` /// use num_traits::real::Real; @@ -244,7 +244,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg { /// Raise a number to an integer power. /// - /// Using this function is generally faster than using `powf` + /// Using this function is generally faster than using + /// [`powf`](Self::powf()) /// /// ``` /// use num_traits::real::Real; diff --git a/src/sign.rs b/src/sign.rs index a0d6b0fd..0097aa7a 100644 --- a/src/sign.rs +++ b/src/sign.rs @@ -34,10 +34,10 @@ pub trait Signed: Sized + Num + Neg { /// * `-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. + /// Returns `true` if the number is positive and `false` if the number is zero or negative. fn is_positive(&self) -> bool; - /// Returns true if the number is negative and false if the number is zero or positive. + /// Returns `true` if the number is negative and `false` if the number is zero or positive. fn is_negative(&self) -> bool; }