Struct overflow_error::WouldOverflow
[−]
[src]
pub struct WouldOverflow;
Operation was not performed, as it would result in overflow or underflow.
Methods
impl WouldOverflow[src]
pub fn val<T>(self, val: T) -> WouldOverflowValue<T>[src]
Adds a payload to this error.
Examples
use overflow_error::*; fn checked_add(a: u32, b: u32) -> Result<u32, WouldOverflowValue<u32>> { a.checked_add(b).ok_or(WouldOverflow.val(a)) } assert_eq!( *checked_add(u32::max_value(), 1).unwrap_err().as_inner(), u32::max_value(), );
impl WouldOverflow[src]
pub fn as_str(&self) -> &'static str[src]
String representing the error.
Examples
use overflow_error::WouldOverflow; assert_eq!( WouldOverflow.as_str(), "operation was not performed, as it would overflow", );
Trait Implementations
impl From<WouldOverflow> for CannotDiv[src]
fn from(_: WouldOverflow) -> CannotDiv[src]
Performs the conversion.
impl Copy for WouldOverflow[src]
impl Clone for WouldOverflow[src]
fn clone(&self) -> WouldOverflow[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Debug for WouldOverflow[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl PartialEq for WouldOverflow[src]
fn eq(&self, __arg_0: &WouldOverflow) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl Eq for WouldOverflow[src]
impl Hash for WouldOverflow[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)[src]
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more