pub trait Primitive:
Clone
+ Copy
+ Eq
+ PartialEq
+ PartialOrd
+ Ord
+ Debug
+ Display {
// Required methods
fn as_i8(self) -> i8;
fn as_i16(self) -> i16;
fn as_i32(self) -> i32;
fn as_i64(self) -> i64;
fn from_i8(n: i8) -> Self;
fn from_i16(n: i16) -> Self;
fn from_i32(n: i32) -> Self;
fn from_i64(n: i64) -> Self;
fn checked_add(self, n: Self) -> Option<Self>;
fn checked_mul(self, n: Self) -> Option<Self>;
}Expand description
A trait for making x as int_type usable in a generic context.
All of these methods require callers to ensure the cast is correct.
However, when debug_assertions is enabled, the casts will result in
a panic if they are incorrect.
Because of the extra checks when debug_assertions is enabled, Jiff tries
to use these routines wherever possible in lieu of as. The primary
downside of using this trait is that it doesn’t work in a const context
because Rust does not yet support generics in const.
Required Methods§
fn as_i8(self) -> i8
fn as_i16(self) -> i16
fn as_i32(self) -> i32
fn as_i64(self) -> i64
fn from_i8(n: i8) -> Self
fn from_i16(n: i16) -> Self
fn from_i32(n: i32) -> Self
fn from_i64(n: i64) -> Self
fn checked_add(self, n: Self) -> Option<Self>
fn checked_mul(self, n: Self) -> Option<Self>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".