Trait Float

Source
pub trait Float<F>:
    PartialOrd<F>
    + FloatAlone
    + Add<F, Output = Self>
    + Sub<F, Output = Self>
    + Mul<F, Output = Self>
    + Rem<F, Output = Self>
    + Div<F, Output = Self>
    + AddAssign<F>
    + SubAssign<F>
    + MulAssign<F>
    + DivAssign<F>
    + RemAssign<F>
where Self: Sized,
{ // Required methods unsafe fn new(from: F) -> Self; fn take(self) -> F; }
Expand description

Generic float trait, implemented by {FFloat, f32, f64}. Takes a “base” argument, intended to be set to {f32, f64}. The main purpose of this is to be taken (generically) by optionally fast functions.

§Safety

Please note that calling these functions on a FFloat may incur UB. These functions are not marked unsafe, as the entire FFloat type is essentially unsafe. Calling these functions on a f32 is perfectly safe, even the unsafe marked functions (although theres not much point in doing so).

Required Methods§

Source

unsafe fn new(from: F) -> Self

Returns a new Self from the float.

§Safety

Refer to Self’s safety documentation. This function is unsafe only when used with a FFloat; Calling it with a f64 or a f32 is safe.

Source

fn take(self) -> F

Returns this float

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Float<f32> for f32

Source§

unsafe fn new(from: f32) -> f32

Returns the input value. This function is safe to call.

Source§

fn take(self) -> f32

Source§

impl Float<f64> for f64

Source§

unsafe fn new(from: f64) -> f64

Returns the input value. This function is safe to call.

Source§

fn take(self) -> f64

Implementors§

Source§

impl<F: FastFloat + Float<F>> Float<F> for FFloat<F>