pub struct i31(/* private fields */);
Expand description
The 31-bit signed integer type.
Implementations§
source§impl i31
impl i31
sourcepub fn min_value() -> i31
pub fn min_value() -> i31
Returns the smallest value that can be represented by this integer type.
sourcepub fn max_value() -> i31
pub fn max_value() -> i31
Returns the largest value that can be represented by this integer type.
sourcepub const fn new(value: i32) -> i31
pub const fn new(value: i32) -> i31
Crates a new variable
This function mainly exists as there is currently not a better way to construct these types. May be deprecated or removed if a better way to construct these types becomes available.
§Examples
Basic usage:
use ux::*;
assert_eq!(u31::new(64), u31::from(64u8));
§Panic
This function will panic if value
is not representable by this type
sourcepub fn wrapping_sub(self, rhs: Self) -> Self
pub fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. Computes self - other
,
wrapping around at the boundary of the type.
§Examples
Basic usage:
use ux::*;
assert_eq!(i5::MIN.wrapping_sub(i5::new(1)), i5::MAX);
assert_eq!(i5::new(-10).wrapping_sub(i5::new(5)), i5::new(-15));
assert_eq!(i5::new(-15).wrapping_sub(i5::new(5)), i5::new(12));
sourcepub fn wrapping_add(self, rhs: Self) -> Self
pub fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. Computes self + other
,
wrapping around at the boundary of the type.
§Examples
Basic usage:
use ux::*;
assert_eq!(i5::MAX.wrapping_add(i5::new(1)), i5::MIN);
assert_eq!(i5::new(10).wrapping_add(i5::new(5)), i5::new(15));
assert_eq!(i5::new(15).wrapping_add(i5::new(5)), i5::new(-12));
Trait Implementations§
source§impl BitAndAssign for i31
impl BitAndAssign for i31
source§fn bitand_assign(&mut self, other: i31)
fn bitand_assign(&mut self, other: i31)
Performs the
&=
operation. Read moresource§impl BitOrAssign for i31
impl BitOrAssign for i31
source§fn bitor_assign(&mut self, other: i31)
fn bitor_assign(&mut self, other: i31)
Performs the
|=
operation. Read moresource§impl BitXorAssign for i31
impl BitXorAssign for i31
source§fn bitxor_assign(&mut self, other: i31)
fn bitxor_assign(&mut self, other: i31)
Performs the
^=
operation. Read moresource§impl Ord for i31
impl Ord for i31
source§impl PartialEq for i31
impl PartialEq for i31
source§impl PartialOrd for i31
impl PartialOrd for i31
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<T> ShlAssign<T> for i31
impl<T> ShlAssign<T> for i31
source§fn shl_assign(&mut self, rhs: T)
fn shl_assign(&mut self, rhs: T)
Performs the
<<=
operation. Read moresource§impl<T> ShrAssign<T> for i31
impl<T> ShrAssign<T> for i31
source§fn shr_assign(&mut self, rhs: T)
fn shr_assign(&mut self, rhs: T)
Performs the
>>=
operation. Read moreimpl Copy for i31
impl Eq for i31
Auto Trait Implementations§
impl Freeze for i31
impl RefUnwindSafe for i31
impl Send for i31
impl Sync for i31
impl Unpin for i31
impl UnwindSafe for i31
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more