Struct overflow_error::Overflowed
[−]
[src]
pub struct Overflowed;
Operation was performed and overflowed or underflowed.
Methods
impl Overflowed
[src]
pub fn val<T>(self, val: T) -> OverflowedValue<T>
[src]
Adds a payload to this error, indicating the overflowed result.
Examples
use overflow_error::*; fn overflowing_add(a: u32, b: u32) -> Result<u32, OverflowedValue<u32>> { let (c, overflowed) = a.overflowing_add(b); if overflowed { Err(Overflowed.val(c)) } else { Ok(c) } } let result = overflowing_add(u32::max_value(), 1); assert!(*result.unwrap_err().as_inner() == 0);
impl Overflowed
[src]
pub fn as_str(&self) -> &'static str
[src]
String representing the error.
Examples
use overflow_error::*; assert!(Overflowed.as_str() == "operation overflowed");
Trait Implementations
impl Copy for Overflowed
[src]
impl Clone for Overflowed
[src]
fn clone(&self) -> Overflowed
[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 Overflowed
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl PartialEq for Overflowed
[src]
fn eq(&self, __arg_0: &Overflowed) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for Overflowed
[src]
impl Hash for Overflowed
[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