Skip to main content

Trunc

Struct Trunc 

Source
pub struct Trunc;
Expand description

Truncation towards zero

Excess precision is truncated (rounds towards zero). This is the rounding mode used by as numeric casts for floating-point to integer conversions.

Example: 2.9_f32 converts to 2_i32, -2.9_f32 converts to -2_i32.

The § Limits of approximation as specified by Approx apply.

Trait Implementations§

Source§

impl Clone for Trunc

Source§

fn clone(&self) -> Trunc

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S, T: ConvExact<S>> ConvTo<S, Trunc> for T

Available on crate features libm or std only.
Source§

type Error = <T as ConvExact<S>>::Error

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, s: S) -> Result<Self, Self::Error>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, s: S) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for i8

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for i16

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for i32

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for i64

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for i128

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for isize

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for u8

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for u16

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for u32

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for u64

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for usize

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f32, Trunc> for u128

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f32) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f32) -> u128

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for i8

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for i16

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for i32

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for i64

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for i128

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for isize

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for u8

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for u16

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for u32

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for u64

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for u128

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl ConvTo<f64, Trunc> for usize

Source§

type Error = RangeError

Conversion error type Read more
Source§

fn try_conv_to(_: Trunc, x: f64) -> Result<Self, RangeError>

Try converting from S to Self, rounding according to mode
Source§

fn conv_to(_: Trunc, x: f64) -> Self

Convert from S to Self, rounding according to mode Read more
Source§

impl Copy for Trunc

Source§

impl Debug for Trunc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Trunc

Source§

fn default() -> Trunc

Returns the “default value” for a type. Read more
Source§

impl Rounding for Trunc

Source§

type MaximumError = RangeError

Maximum error type

Auto Trait Implementations§

§

impl Freeze for Trunc

§

impl RefUnwindSafe for Trunc

§

impl Send for Trunc

§

impl Sync for Trunc

§

impl Unpin for Trunc

§

impl UnsafeUnpin for Trunc

§

impl UnwindSafe for Trunc

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S, T> Cast<T> for S
where T: Conv<S>,

Source§

type Error = <T as Conv<S>>::Error

Conversion error type Read more
Source§

fn cast(self) -> T

Cast from Self to T Read more
Source§

fn try_cast(self) -> Result<T, <S as Cast<T>>::Error>

Try converting from Self to T
Source§

impl<S, T> CastApprox<T> for S
where T: ConvApprox<S>,

Source§

type Error = <T as ConvApprox<S>>::Error

Conversion error type Read more
Source§

fn try_cast_approx(self) -> Result<T, <S as CastApprox<T>>::Error>

Try approximate conversion from Self to T
Source§

fn cast_approx(self) -> T

Cast approximately from Self to T Read more
Source§

impl<R, S, T> CastTo<T, R> for S
where R: Rounding, T: ConvTo<S, R>,

Source§

type Error = <T as ConvTo<S, R>>::Error

Conversion error type Read more
Source§

fn try_cast_to(self, mode: R) -> Result<T, <S as CastTo<T, R>>::Error>

Try converting from Self to T, rounding according to mode
Source§

fn cast_to(self, mode: R) -> T

Convert from Self to T, rounding according to mode Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.