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
impl CheckedU16
Sourcepub fn new(v: u16) -> Self
pub fn new(v: u16) -> Self
Creates a new $cty instance from a $uty value.
Ensures the internal representation matches the provided value.
Sourcepub fn new_overflowed(verus_tmp_i: Ghost<int>) -> Self
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.
Sourcepub fn is_overflowed(&self) -> bool
pub fn is_overflowed(&self) -> bool
Checks if the $cty instance is overflowed.
Returns true if the value is greater than $uty::MAX.
Sourcepub fn unwrap(&self) -> u16
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.
Sourcepub fn to_option(&self) -> Option<u16>
pub fn to_option(&self) -> Option<u16>
Converts the $cty instance to an Option<$uty>.
Ensures the returned option matches the internal representation.
Sourcepub fn add_value(&self, v2: u16) -> Self
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.
Sourcepub fn add_checked(&self, v2: &CheckedU16) -> Self
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.
Sourcepub fn mul_value(&self, v2: u16) -> Self
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.
Sourcepub fn mul_checked(&self, v2: &Self) -> Self
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.