TryFromi32
TryFromi32 is not a distinct type in Rust's standard library; it is a way to refer to fallible conversions from the 32-bit signed integer type to other types using the TryFrom trait. The TryFrom trait, in core::convert, provides a fallible conversion that returns Result<T, TryFromIntError> instead of panicking on overflow.
Implementations exist for converting i32 to many primitive integer types, including i8, u8, i16, u16, and so
Usage patterns include calling the associated function on the destination type, for example i8::try_from(x) where x:
Example: let x: i32 = 42; let r: Result<i8, _> = i8::try_from(x); // Ok(42)
Let y: i32 = 130; let e: Result<i8, _> = y.try_into(); // Err(...)
Rust stabilized TryFrom and TryInto with Rust 1.34 (2019), enabling safe, explicit handling of overflow in conversions