Run cargo fmt --all
This commit is contained in:
parent
4b1ea5fb12
commit
0547a355ee
|
@ -10,7 +10,6 @@ use {Num, NumCast, ToPrimitive};
|
||||||
#[cfg(feature = "libm")]
|
#[cfg(feature = "libm")]
|
||||||
use libm::{F32Ext, F64Ext};
|
use libm::{F32Ext, F64Ext};
|
||||||
|
|
||||||
|
|
||||||
/// Generic trait for floating point numbers that works with `no_std`.
|
/// 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.
|
||||||
|
@ -1835,7 +1834,7 @@ macro_rules! float_impl_std {
|
||||||
$decode(self)
|
$decode(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
forward!{
|
forward! {
|
||||||
Self::is_nan(self) -> bool;
|
Self::is_nan(self) -> bool;
|
||||||
Self::is_infinite(self) -> bool;
|
Self::is_infinite(self) -> bool;
|
||||||
Self::is_finite(self) -> bool;
|
Self::is_finite(self) -> bool;
|
||||||
|
@ -1914,7 +1913,7 @@ macro_rules! float_impl_libm {
|
||||||
$decode(self)
|
$decode(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
forward!{
|
forward! {
|
||||||
FloatCore::is_nan(self) -> bool;
|
FloatCore::is_nan(self) -> bool;
|
||||||
FloatCore::is_infinite(self) -> bool;
|
FloatCore::is_infinite(self) -> bool;
|
||||||
FloatCore::is_finite(self) -> bool;
|
FloatCore::is_finite(self) -> bool;
|
||||||
|
@ -2009,7 +2008,6 @@ float_impl_libm!(f32 integer_decode_f32 F32Ext);
|
||||||
#[cfg(all(not(feature = "std"), feature = "libm"))]
|
#[cfg(all(not(feature = "std"), feature = "libm"))]
|
||||||
float_impl_libm!(f64 integer_decode_f64 F64Ext);
|
float_impl_libm!(f64 integer_decode_f64 F64Ext);
|
||||||
|
|
||||||
|
|
||||||
macro_rules! float_const_impl {
|
macro_rules! float_const_impl {
|
||||||
($(#[$doc:meta] $constant:ident,)+) => (
|
($(#[$doc:meta] $constant:ident,)+) => (
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|
|
@ -155,7 +155,7 @@ pow_impl!(Wrapping<isize>);
|
||||||
#[cfg(any(feature = "std", feature = "libm"))]
|
#[cfg(any(feature = "std", feature = "libm"))]
|
||||||
mod float_impls {
|
mod float_impls {
|
||||||
use super::Pow;
|
use super::Pow;
|
||||||
use ::Float;
|
use Float;
|
||||||
|
|
||||||
pow_impl!(f32, i8, i32, <f32 as Float>::powi);
|
pow_impl!(f32, i8, i32, <f32 as Float>::powi);
|
||||||
pow_impl!(f32, u8, i32, <f32 as Float>::powi);
|
pow_impl!(f32, u8, i32, <f32 as Float>::powi);
|
||||||
|
|
188
src/real.rs
188
src/real.rs
|
@ -20,8 +20,8 @@ use Float;
|
||||||
pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Returns the smallest finite value that this type can represent.
|
/// Returns the smallest finite value that this type can represent.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -33,8 +33,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns the smallest positive, normalized value that this type can represent.
|
/// Returns the smallest positive, normalized value that this type can represent.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -46,8 +46,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns epsilon, a small positive value.
|
/// Returns epsilon, a small positive value.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -64,8 +64,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns the largest finite value that this type can represent.
|
/// Returns the largest finite value that this type can represent.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -76,8 +76,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns the largest integer less than or equal to a number.
|
/// Returns the largest integer less than or equal to a number.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let f = 3.99;
|
/// let f = 3.99;
|
||||||
|
@ -90,8 +90,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns the smallest integer greater than or equal to a number.
|
/// Returns the smallest integer greater than or equal to a number.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let f = 3.01;
|
/// let f = 3.01;
|
||||||
|
@ -105,8 +105,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Returns the nearest integer to a number. Round half-way cases away from
|
/// Returns the nearest integer to a number. Round half-way cases away from
|
||||||
/// `0.0`.
|
/// `0.0`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let f = 3.3;
|
/// let f = 3.3;
|
||||||
|
@ -119,8 +119,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Return the integer part of a number.
|
/// Return the integer part of a number.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let f = 3.3;
|
/// let f = 3.3;
|
||||||
|
@ -133,8 +133,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns the fractional part of a number.
|
/// Returns the fractional part of a number.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 3.5;
|
/// let x = 3.5;
|
||||||
|
@ -150,8 +150,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
|
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
|
||||||
/// number is `Float::nan()`.
|
/// number is `Float::nan()`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -174,8 +174,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()`
|
/// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()`
|
||||||
/// - `Float::nan()` if the number is `Float::nan()`
|
/// - `Float::nan()` if the number is `Float::nan()`
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -191,8 +191,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Returns `true` if `self` is positive, including `+0.0`,
|
/// 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`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -210,8 +210,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Returns `true` if `self` is negative, including `-0.0`,
|
/// 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`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -232,8 +232,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Using `mul_add` can be more performant than an unfused multiply-add if
|
/// Using `mul_add` can be more performant than an unfused multiply-add if
|
||||||
/// the target architecture has a dedicated `fma` CPU instruction.
|
/// the target architecture has a dedicated `fma` CPU instruction.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let m = 10.0;
|
/// let m = 10.0;
|
||||||
|
@ -249,8 +249,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Take the reciprocal (inverse) of a number, `1/x`.
|
/// Take the reciprocal (inverse) of a number, `1/x`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 2.0;
|
/// let x = 2.0;
|
||||||
|
@ -264,8 +264,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
///
|
///
|
||||||
/// Using this function is generally faster than using `powf`
|
/// Using this function is generally faster than using `powf`
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 2.0;
|
/// let x = 2.0;
|
||||||
|
@ -277,8 +277,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Raise a number to a real number power.
|
/// Raise a number to a real number power.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 2.0;
|
/// let x = 2.0;
|
||||||
|
@ -296,8 +296,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
///
|
///
|
||||||
/// If the implementing type doesn't support NaN, this method should panic if `self < 0`.
|
/// If the implementing type doesn't support NaN, this method should panic if `self < 0`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let positive = 4.0;
|
/// let positive = 4.0;
|
||||||
|
@ -312,8 +312,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns `e^(self)`, (the exponential function).
|
/// Returns `e^(self)`, (the exponential function).
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let one = 1.0;
|
/// let one = 1.0;
|
||||||
|
@ -329,8 +329,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns `2^(self)`.
|
/// Returns `2^(self)`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let f = 2.0;
|
/// let f = 2.0;
|
||||||
|
@ -348,8 +348,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
///
|
///
|
||||||
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
|
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let one = 1.0;
|
/// let one = 1.0;
|
||||||
|
@ -369,8 +369,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
///
|
///
|
||||||
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
|
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let ten = 10.0;
|
/// let ten = 10.0;
|
||||||
|
@ -393,8 +393,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
///
|
///
|
||||||
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
|
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let two = 2.0;
|
/// let two = 2.0;
|
||||||
|
@ -413,8 +413,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
|
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let ten = 10.0;
|
/// let ten = 10.0;
|
||||||
|
@ -428,8 +428,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Converts radians to degrees.
|
/// Converts radians to degrees.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use std::f64::consts;
|
/// use std::f64::consts;
|
||||||
///
|
///
|
||||||
/// let angle = consts::PI;
|
/// let angle = consts::PI;
|
||||||
|
@ -442,8 +442,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Converts degrees to radians.
|
/// Converts degrees to radians.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use std::f64::consts;
|
/// use std::f64::consts;
|
||||||
///
|
///
|
||||||
/// let angle = 180.0_f64;
|
/// let angle = 180.0_f64;
|
||||||
|
@ -456,8 +456,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns the maximum of the two numbers.
|
/// Returns the maximum of the two numbers.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 1.0;
|
/// let x = 1.0;
|
||||||
|
@ -469,8 +469,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Returns the minimum of the two numbers.
|
/// Returns the minimum of the two numbers.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 1.0;
|
/// let x = 1.0;
|
||||||
|
@ -485,8 +485,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// * If `self <= other`: `0:0`
|
/// * If `self <= other`: `0:0`
|
||||||
/// * Else: `self - other`
|
/// * Else: `self - other`
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 3.0;
|
/// let x = 3.0;
|
||||||
|
@ -502,8 +502,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Take the cubic root of a number.
|
/// Take the cubic root of a number.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 8.0;
|
/// let x = 8.0;
|
||||||
|
@ -518,8 +518,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Calculate the length of the hypotenuse of a right-angle triangle given
|
/// Calculate the length of the hypotenuse of a right-angle triangle given
|
||||||
/// legs of length `x` and `y`.
|
/// legs of length `x` and `y`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 2.0;
|
/// let x = 2.0;
|
||||||
|
@ -534,8 +534,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Computes the sine of a number (in radians).
|
/// Computes the sine of a number (in radians).
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -549,8 +549,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Computes the cosine of a number (in radians).
|
/// Computes the cosine of a number (in radians).
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -564,8 +564,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Computes the tangent of a number (in radians).
|
/// Computes the tangent of a number (in radians).
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -585,8 +585,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// If this type does not support a NaN representation, this function should panic
|
/// If this type does not support a NaN representation, this function should panic
|
||||||
/// if the number is outside the range [-1, 1].
|
/// if the number is outside the range [-1, 1].
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -608,8 +608,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// If this type does not support a NaN representation, this function should panic
|
/// If this type does not support a NaN representation, this function should panic
|
||||||
/// if the number is outside the range [-1, 1].
|
/// if the number is outside the range [-1, 1].
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -625,8 +625,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Computes the arctangent of a number. Return value is in radians in the
|
/// Computes the arctangent of a number. Return value is in radians in the
|
||||||
/// range [-pi/2, pi/2];
|
/// range [-pi/2, pi/2];
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let f = 1.0;
|
/// let f = 1.0;
|
||||||
|
@ -645,8 +645,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
|
/// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
|
||||||
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
|
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -671,8 +671,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
|
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
|
||||||
/// `(sin(x), cos(x))`.
|
/// `(sin(x), cos(x))`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -690,8 +690,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// Returns `e^(self) - 1` in a way that is accurate even if the
|
/// Returns `e^(self) - 1` in a way that is accurate even if the
|
||||||
/// number is close to zero.
|
/// number is close to zero.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 7.0;
|
/// let x = 7.0;
|
||||||
|
@ -711,8 +711,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
/// If this type does not support a NaN representation, this function should panic
|
/// If this type does not support a NaN representation, this function should panic
|
||||||
/// if `self-1 <= 0`.
|
/// if `self-1 <= 0`.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -727,8 +727,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Hyperbolic sine function.
|
/// Hyperbolic sine function.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -746,8 +746,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Hyperbolic cosine function.
|
/// Hyperbolic cosine function.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -765,8 +765,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Hyperbolic tangent function.
|
/// Hyperbolic tangent function.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
@ -784,8 +784,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Inverse hyperbolic sine function.
|
/// Inverse hyperbolic sine function.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 1.0;
|
/// let x = 1.0;
|
||||||
|
@ -799,8 +799,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Inverse hyperbolic cosine function.
|
/// Inverse hyperbolic cosine function.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
///
|
///
|
||||||
/// let x = 1.0;
|
/// let x = 1.0;
|
||||||
|
@ -814,8 +814,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
|
||||||
|
|
||||||
/// Inverse hyperbolic tangent function.
|
/// Inverse hyperbolic tangent function.
|
||||||
///
|
///
|
||||||
#[cfg_attr(any(feature = "std", feature = "libm"), doc=" ```")]
|
#[cfg_attr(any(feature = "std", feature = "libm"), doc = " ```")]
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc=" ```ignore")]
|
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc = " ```ignore")]
|
||||||
/// use num_traits::real::Real;
|
/// use num_traits::real::Real;
|
||||||
/// use std::f64;
|
/// use std::f64;
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue