#![deny(missing_docs)]
#![no_std]
#[cfg(feature = "std")]
extern crate std;
#[cfg(all(not(feature = "std"), feature = "libm"))]
extern crate libm;
use core::num::FpCategory;
pub use num_traits;
macro_rules! define_prefix_methods {
(
$(
$( #[$module_attrs:meta] )*
$trait_path:path => $module_name:ident {
$(
$( #[$method_attrs:meta] )*
$method_name:ident $method_args:tt -> $method_result:tt
)*
}
)*
) => {
$(
$( #[$module_attrs] )*
#[allow(unused_imports)]
pub mod $module_name {
use super::*;
$(
define_method! {
$( #[$method_attrs] )*
$trait_path : $method_name $method_args -> $method_result
}
)*
}
)*
}
}
macro_rules! define_method {
(
$( #[$method_attrs:meta] )*
$trait_path:path : $method_name:ident ( $( $arg:ident : $arg_ty:tt ),* ) -> $return_type:tt
) => {
$( #[$method_attrs] )*
pub fn $method_name<Self_: $trait_path>( $( $arg : translate_type!($arg_ty) ),* ) -> translate_type!($return_type) {
<Self_ as $trait_path>::$method_name( $( $arg ),* )
}
};
(
$( #[$method_attrs:meta] )*
$trait_path:path : $method_name:ident (self $(,)? $( $arg:ident: $arg_ty:tt ),* ) -> $return_type:tt
) => {
$( #[$method_attrs] )*
pub fn $method_name<Self_: $trait_path>(self_: Self_, $( $arg : translate_type!($arg_ty) ),* ) -> translate_type!($return_type) {
self_.$method_name( $( $arg ),* )
}
};
(
$( #[$method_attrs:meta] )*
$trait_path:path : $method_name:ident(&self) -> $return_type:tt
) => {
$( #[$method_attrs] )*
pub fn $method_name<Self_: $trait_path>(self_: &Self_) -> translate_type!($return_type) {
self_.$method_name()
}
};
}
macro_rules! translate_type {
( Self ) => { Self_ };
( ( Self::$assoc_type:ident ) ) => { Self_::$assoc_type };
( ( $generic:ident< $($param:tt),* > ) ) => { $generic< $( translate_type!($param) ),* > };
( ( $( $tuple_member:tt ),* ) ) => { ( $( translate_type!($tuple_member) ),* ) };
( ( $other:ty ) ) => { $other };
( $other:ty ) => { $other };
}
define_prefix_methods! {
num_traits::bounds::Bounded => bounded {
min_value() -> Self
max_value() -> Self
}
num_traits::cast::FromPrimitive => from_primitive {
from_i64(n: i64) -> (Option<Self>)
from_u64(n: u64) -> (Option<Self>)
from_isize(n: isize) -> (Option<Self>)
from_i8(n: i8) -> (Option<Self>)
from_i16(n: i16) -> (Option<Self>)
from_i32(n: i32) -> (Option<Self>)
from_usize(n: usize) -> (Option<Self>)
from_u8(n: u8) -> (Option<Self>)
from_u16(n: u16) -> (Option<Self>)
from_u32(n: u32) -> (Option<Self>)
from_f32(n: f32) -> (Option<Self>)
from_f64(n: f64) -> (Option<Self>)
}
num_traits::cast::ToPrimitive => to_primitive {
to_i64(&self) -> (Option<i64>)
to_u64(&self) -> (Option<u64>)
to_isize(&self) -> (Option<isize>)
to_i8(&self) -> (Option<i8>)
to_i16(&self) -> (Option<i16>)
to_i32(&self) -> (Option<i32>)
to_usize(&self) -> (Option<usize>)
to_u8(&self) -> (Option<u8>)
to_u16(&self) -> (Option<u16>)
to_u32(&self) -> (Option<u32>)
to_f32(&self) -> (Option<f32>)
to_f64(&self) -> (Option<f64>)
}
#[cfg(any(feature = "std", feature = "libm"))]
num_traits::float::Float => float {
nan() -> Self
infinity() -> Self
neg_infinity() -> Self
neg_zero() -> Self
min_value() -> Self
min_positive_value() -> Self
max_value() -> Self
is_nan(self) -> bool
is_infinite(self) -> bool
is_finite(self) -> bool
is_normal(self) -> bool
classify(self) -> FpCategory
floor(self) -> Self
ceil(self) -> Self
round(self) -> Self
trunc(self) -> Self
fract(self) -> Self
abs(self) -> Self
signum(self) -> Self
is_sign_positive(self) -> bool
is_sign_negative(self) -> bool
mul_add(self, a: Self, b: Self) -> Self
recip(self) -> Self
powi(self, n: i32) -> Self
powf(self, n: Self) -> Self
sqrt(self) -> Self
exp(self) -> Self
exp2(self) -> Self
ln(self) -> Self
log(self, base: Self) -> Self
log2(self) -> Self
log10(self) -> Self
max(self, other: Self) -> Self
min(self, other: Self) -> Self
abs_sub(self, other: Self) -> Self
cbrt(self) -> Self
hypot(self, other: Self) -> Self
sin(self) -> Self
cos(self) -> Self
tan(self) -> Self
asin(self) -> Self
acos(self) -> Self
atan(self) -> Self
atan2(self, other: Self) -> Self
sin_cos(self) -> (Self, Self)
exp_m1(self) -> Self
ln_1p(self) -> Self
sinh(self) -> Self
cosh(self) -> Self
tanh(self) -> Self
asinh(self) -> Self
acosh(self) -> Self
atanh(self) -> Self
integer_decode(self) -> (u64, i16, i8)
epsilon() -> Self
to_degrees(self) -> Self
to_radians(self) -> Self
}
#[allow(non_snake_case)]
num_traits::float::FloatConst => float_const {
E() -> Self
FRAC_1_PI() -> Self
FRAC_1_SQRT_2() -> Self
FRAC_2_PI() -> Self
FRAC_2_SQRT_PI() -> Self
FRAC_PI_2() -> Self
FRAC_PI_3() -> Self
FRAC_PI_4() -> Self
FRAC_PI_6() -> Self
FRAC_PI_8() -> Self
LN_10() -> Self
LN_2() -> Self
LOG10_E() -> Self
LOG2_E() -> Self
PI() -> Self
SQRT_2() -> Self
}
num_traits::float::FloatCore => float_core {
infinity() -> Self
neg_infinity() -> Self
nan() -> Self
neg_zero() -> Self
min_value() -> Self
min_positive_value() -> Self
epsilon() -> Self
max_value() -> Self
classify(self) -> FpCategory
to_degrees(self) -> Self
to_radians(self) -> Self
integer_decode(self) -> (u64, i16, i8)
is_nan(self) -> bool
is_infinite(self) -> bool
is_finite(self) -> bool
is_normal(self) -> bool
floor(self) -> Self
ceil(self) -> Self
round(self) -> Self
trunc(self) -> Self
fract(self) -> Self
abs(self) -> Self
signum(self) -> Self
is_sign_positive(self) -> bool
is_sign_negative(self) -> bool
min(self, other: Self) -> Self
max(self, other: Self) -> Self
recip(self) -> Self
powi(self, exp: i32) -> Self
}
num_traits::int::PrimInt => prim_int {
count_ones(self) -> u32
count_zeros(self) -> u32
leading_zeros(self) -> u32
trailing_zeros(self) -> u32
rotate_left(self, n: u32) -> Self
rotate_right(self, n: u32) -> Self
signed_shl(self, n: u32) -> Self
signed_shr(self, n: u32) -> Self
unsigned_shl(self, n: u32) -> Self
unsigned_shr(self, n: u32) -> Self
swap_bytes(self) -> Self
from_be(x: Self) -> Self
from_le(x: Self) -> Self
to_be(self) -> Self
to_le(self) -> Self
pow(self, exp: u32) -> Self
}
num_traits::Num => num {
from_str_radix(str: (&str), radix: u32) -> (Result<Self, (Self::FromStrRadixErr)>)
}
num_traits::ops::checked::CheckedNeg => checked_neg {
checked_neg(&self) -> (Option<Self>)
}
num_traits::ops::inv::Inv => inv {
inv(self) -> (Self::Output)
}
num_traits::ops::wrapping::WrappingNeg => wrapping_neg {
wrapping_neg(&self) -> Self
}
#[cfg(any(feature = "std", feature = "libm"))]
num_traits::real::Real => real {
min_value() -> Self
min_positive_value() -> Self
epsilon() -> Self
max_value() -> Self
floor(self) -> Self
ceil(self) -> Self
round(self) -> Self
trunc(self) -> Self
fract(self) -> Self
abs(self) -> Self
signum(self) -> Self
is_sign_positive(self) -> bool
is_sign_negative(self) -> bool
mul_add(self, a: Self, b: Self) -> Self
recip(self) -> Self
powi(self, n: i32) -> Self
powf(self, n: Self) -> Self
sqrt(self) -> Self
exp(self) -> Self
exp2(self) -> Self
ln(self) -> Self
log(self, base: Self) -> Self
log2(self) -> Self
log10(self) -> Self
to_degrees(self) -> Self
to_radians(self) -> Self
max(self, other: Self) -> Self
min(self, other: Self) -> Self
abs_sub(self, other: Self) -> Self
cbrt(self) -> Self
hypot(self, other: Self) -> Self
sin(self) -> Self
cos(self) -> Self
tan(self) -> Self
asin(self) -> Self
acos(self) -> Self
atan(self) -> Self
atan2(self, other: Self) -> Self
sin_cos(self) -> (Self, Self)
exp_m1(self) -> Self
ln_1p(self) -> Self
sinh(self) -> Self
cosh(self) -> Self
tanh(self) -> Self
asinh(self) -> Self
acosh(self) -> Self
atanh(self) -> Self
}
}