Skip to main content

TryTruncateInto

Trait TryTruncateInto 

Source
pub trait TryTruncateInto<T, E> {
    // Required method
    fn try_truncate_into(self) -> Result<T, E>;
}
Expand description

Convert one type to another by rounding to the nearest integer towards zero.

§Errors

Traps when the input float cannot be represented by the target integer or when the input float is NaN.

Required Methods§

Source

fn try_truncate_into(self) -> Result<T, E>

Convert one type to another by rounding to the nearest integer towards zero.

§Errors
  • If the input float value is NaN (not a number).
  • If the input float value cannot be represented using the truncated integer type.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TryTruncateInto<i32, TrapCode> for f32

Source§

impl TryTruncateInto<i32, TrapCode> for f64

Source§

impl TryTruncateInto<i64, TrapCode> for f32

Source§

impl TryTruncateInto<i64, TrapCode> for f64

Source§

impl TryTruncateInto<u32, TrapCode> for f32

Source§

impl TryTruncateInto<u32, TrapCode> for f64

Source§

impl TryTruncateInto<u64, TrapCode> for f32

Source§

impl TryTruncateInto<u64, TrapCode> for f64

Implementors§