Struct Nearest Copy item path Source pub struct Nearest;Available on crate features libm or std only.
Expand description Round to the nearest representable value
The precise behaviour of half-way cases is implementation-defined. Provided
implementations follow common practices: float-to-int conversions use the
round() inherent function which rounds away from zero while int-to-float
conversions follow the behaviour of as numeric casts which rounds ties
to even.
Example: 2.5_f32 converts to 3_i32, -2.5_f32 converts to -3_i32.
Another example: converting i32::MAX to f32 rounds up to
231 .
The § Limits of approximation as
specified by Approx apply.
Performs copy-assignment from
source.
Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Convert from
S to
Self, rounding according to
mode Read more Try converting from S to Self, rounding according to mode
Formats the value using the given formatter.
Read more Returns the “default value” for a type.
Read more Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more Try converting from Self to T
Try approximate conversion from Self to T
Try converting from Self to T, rounding according to mode
Convert from
Self to
T, rounding according to
mode Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.