pub struct CheckedInt<T> { /* private fields */ }Expand description
Ring on numeric values that panics on overflow.
Computes exactly like any signed numeric value, but panics on overflow.
Implementations§
Source§impl<T> CheckedInt<T>
impl<T> CheckedInt<T>
pub const fn new(value: T) -> Self
pub fn into_inner(self) -> T
Trait Implementations§
Source§impl<T> Add for CheckedInt<T>where
T: CheckedAdd,
impl<T> Add for CheckedInt<T>where
T: CheckedAdd,
Source§impl<T> AddAssign for CheckedInt<T>where
T: CheckedAdd,
impl<T> AddAssign for CheckedInt<T>where
T: CheckedAdd,
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl<T> AddAssignByRef for CheckedInt<T>where
T: CheckedAdd,
impl<T> AddAssignByRef for CheckedInt<T>where
T: CheckedAdd,
fn add_assign_by_ref(&mut self, other: &Self)
Source§impl<T> AddByRef for CheckedInt<T>where
T: CheckedAdd,
impl<T> AddByRef for CheckedInt<T>where
T: CheckedAdd,
fn add_by_ref(&self, other: &Self) -> Self
Source§impl<T> Archive for CheckedInt<T>where
T: Archive,
impl<T> Archive for CheckedInt<T>where
T: Archive,
Source§impl<T: Clone> Clone for CheckedInt<T>
impl<T: Clone> Clone for CheckedInt<T>
Source§fn clone(&self) -> CheckedInt<T>
fn clone(&self) -> CheckedInt<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<T: Copy> Copy for CheckedInt<T>
Source§impl<T> Debug for CheckedInt<T>where
T: Debug,
impl<T> Debug for CheckedInt<T>where
T: Debug,
Source§impl<T: Default> Default for CheckedInt<T>
impl<T: Default> Default for CheckedInt<T>
Source§fn default() -> CheckedInt<T>
fn default() -> CheckedInt<T>
Returns the “default value” for a type. Read more
Source§impl<__D: Fallible + ?Sized, T> Deserialize<CheckedInt<T>, __D> for Archived<CheckedInt<T>>
impl<__D: Fallible + ?Sized, T> Deserialize<CheckedInt<T>, __D> for Archived<CheckedInt<T>>
Source§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<CheckedInt<T>, __D::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<CheckedInt<T>, __D::Error>
Deserializes using the given deserializer
Source§impl<T> Display for CheckedInt<T>where
T: Display,
impl<T> Display for CheckedInt<T>where
T: Display,
impl<T: Eq> Eq for CheckedInt<T>
Source§impl<T> From<T> for CheckedInt<T>
impl<T> From<T> for CheckedInt<T>
Source§impl<T> HasZero for CheckedInt<T>where
T: HasZero,
impl<T> HasZero for CheckedInt<T>where
T: HasZero,
Source§impl<T: Hash> Hash for CheckedInt<T>
impl<T: Hash> Hash for CheckedInt<T>
Source§impl<T> MulByRef for CheckedInt<T>where
T: CheckedMul,
impl<T> MulByRef for CheckedInt<T>where
T: CheckedMul,
type Output = CheckedInt<T>
fn mul_by_ref(&self, rhs: &Self) -> Self::Output
Source§impl<T> Neg for CheckedInt<T>where
T: CheckedNeg,
impl<T> Neg for CheckedInt<T>where
T: CheckedNeg,
Source§impl<T> NegByRef for CheckedInt<T>where
T: CheckedNeg,
impl<T> NegByRef for CheckedInt<T>where
T: CheckedNeg,
fn neg_by_ref(&self) -> Self
Source§impl<T: Ord> Ord for CheckedInt<T>
impl<T: Ord> Ord for CheckedInt<T>
Source§fn cmp(&self, other: &CheckedInt<T>) -> Ordering
fn cmp(&self, other: &CheckedInt<T>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq> PartialEq for CheckedInt<T>
impl<T: PartialEq> PartialEq for CheckedInt<T>
Source§fn eq(&self, other: &CheckedInt<T>) -> bool
fn eq(&self, other: &CheckedInt<T>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<T> PartialEq<T> for CheckedInt<T>where
T: PartialEq,
impl<T> PartialEq<T> for CheckedInt<T>where
T: PartialEq,
Source§impl<T: PartialOrd> PartialOrd for CheckedInt<T>
impl<T: PartialOrd> PartialOrd for CheckedInt<T>
Source§impl<T> PartialOrd<T> for CheckedInt<T>where
T: PartialOrd,
impl<T> PartialOrd<T> for CheckedInt<T>where
T: PartialOrd,
Source§impl<T> SizeOf for CheckedInt<T>where
T: SizeOf,
impl<T> SizeOf for CheckedInt<T>where
T: SizeOf,
Source§fn size_of_children(&self, context: &mut Context)
fn size_of_children(&self, context: &mut Context)
Gets the size of all “children” owned by this value, not including the
size of the value itself. Read more
Source§fn size_of_with_context(&self, context: &mut Context)
fn size_of_with_context(&self, context: &mut Context)
Adds the size of the current value to the given
Context,
including both the size of the value itself and all of its childrenimpl<T: PartialEq> StructuralPartialEq for CheckedInt<T>
Auto Trait Implementations§
impl<T> Freeze for CheckedInt<T>where
T: Freeze,
impl<T> RefUnwindSafe for CheckedInt<T>where
T: RefUnwindSafe,
impl<T> Send for CheckedInt<T>where
T: Send,
impl<T> Sync for CheckedInt<T>where
T: Sync,
impl<T> Unpin for CheckedInt<T>where
T: Unpin,
impl<T> UnsafeUnpin for CheckedInt<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for CheckedInt<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
The archived counterpart of this type. Unlike
Archive, it may be unsized. Read moreSource§type MetadataResolver = ()
type MetadataResolver = ()
The resolver for the metadata of this type. Read more
Source§unsafe fn resolve_metadata(
&self,
_: usize,
_: <T as ArchiveUnsized>::MetadataResolver,
_: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata,
)
unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, )
Creates the archived version of the metadata for this value at the given position and writes
it to the given output. Read more
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
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Comparable for T
impl<T> Comparable for T
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> CustomError for T
impl<T> CustomError for T
impl<T> Data for Twhere
T: Clone + 'static,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> GroupValue for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.