Trait AsPrimitive
Source pub trait AsPrimitive:
Copy
+ PartialEq
+ PartialOrd
+ Send
+ Sync
+ Sized {
Show 18 methods
// Required methods
fn as_u8(self) -> u8;
fn as_u16(self) -> u16;
fn as_u32(self) -> u32;
fn as_u64(self) -> u64;
fn as_u128(self) -> u128;
fn as_usize(self) -> usize;
fn as_i8(self) -> i8;
fn as_i16(self) -> i16;
fn as_i32(self) -> i32;
fn as_i64(self) -> i64;
fn as_i128(self) -> i128;
fn as_isize(self) -> isize;
fn as_f32(self) -> f32;
fn as_f64(self) -> f64;
fn from_u32(value: u32) -> Self;
fn from_u64(value: u64) -> Self;
fn as_f16(self) -> f16;
fn as_bf16(self) -> bf16;
}
Expand description
Type that can be converted to primitive
values with as
.
Convert the value to a u8
, as if by value as u8
.
Convert the value to a u16
, as if by value as u16
.
Convert the value to a u32
, as if by value as u32
.
Convert the value to a u64
, as if by value as u64
.
Convert the value to a u128
, as if by value as u128
.
Convert the value to a usize
, as if by value as usize
.
Convert the value to an i8
, as if by value as i8
.
Convert the value to an i16
, as if by value as i16
.
Convert the value to an i32
, as if by value as i32
.
Convert the value to an i64
, as if by value as i64
.
Convert the value to an i128
, as if by value as i128
.
Convert the value to an isize
, as if by value as isize
.
Convert the value to an f32
, as if by value as f32
.
Convert the value to an f64
, as if by value as f64
.
Convert the value from a u32
, as if by value as _
.
Convert the value from a u64
, as if by value as _
.
Available on crate feature f16
only.
Convert the value to an f16
, identical to value as f16
if f16
was a primitive type.
Available on crate feature f16
only.
Convert the value to an bf16
, identical to value as bf16
if bf16
was a primitive type.
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.
Available on crate feature f16
only.