Skip to main content

CheckedU16

Struct CheckedU16 

Source
pub struct CheckedU16 { /* private fields */ }
Expand description

This struct represents a $uty value that can overflow. The i field is a ghost value that represents the true value, while the v field is None when the value has overflowed and Some(x) when the value x fits in a $uty.

Implementations§

Source§

impl CheckedU16

Source

pub fn new(v: u16) -> Self

Creates a new $cty instance from a $uty value. Ensures the internal representation matches the provided value.

Source

pub fn new_overflowed(verus_tmp_i: Ghost<int>) -> Self

Creates a new $cty instance with an overflowed value. Requires the provided value to be greater than $uty::MAX. Ensures the internal representation matches the provided value.

Source

pub fn is_overflowed(&self) -> bool

Checks if the $cty instance is overflowed. Returns true if the value is greater than $uty::MAX.

Source

pub fn unwrap(&self) -> u16

Unwraps the $cty instance to get the $uty value. Requires the instance to not be overflowed. Ensures the returned value matches the internal representation.

Source

pub fn to_option(&self) -> Option<u16>

Converts the $cty instance to an Option<$uty>. Ensures the returned option matches the internal representation.

Source

pub fn add_value(&self, v2: u16) -> Self

Adds a $uty value to the $cty instance. Ensures the resulting value matches the sum of the internal representation and the provided value.

Source

pub fn add_checked(&self, v2: &CheckedU16) -> Self

Adds another $cty instance to the current instance. Ensures the resulting value matches the sum of the internal representations of both instances.

Source

pub fn mul_value(&self, v2: u16) -> Self

Multiplies the $cty instance by a $uty value. Ensures the resulting value matches the product of the internal representation and the provided value.

Source

pub fn mul_checked(&self, v2: &Self) -> Self

Multiplies the $cty instance by another $cty instance. Ensures the resulting value matches the product of the internal representations of both instances.

Trait Implementations§

Source§

impl Clone for CheckedU16

Source§

fn clone(&self) -> Self

Clones the $cty instance. Ensures the cloned instance has the same value as the original.

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl View for CheckedU16

The view of an $cty instance is the true value of the instance.

Source§

type V = nat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.