Struct overflow_error::Overflowed [] [src]

pub struct Overflowed;

Operation was performed and overflowed or underflowed.

Methods

impl Overflowed
[src]

[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]

[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]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Overflowed
[src]

[src]

Formats the value using the given formatter. Read more

impl PartialEq for Overflowed
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Eq for Overflowed
[src]

impl Hash for Overflowed
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Display for Overflowed
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Overflowed

impl Sync for Overflowed