Struct overflow_error::WouldOverflow [] [src]

pub struct WouldOverflow;

Operation was not performed, as it would result in overflow or underflow.

Methods

impl WouldOverflow
[src]

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

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

[src]

Performs the conversion.

impl Copy for WouldOverflow
[src]

impl Clone for WouldOverflow
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for WouldOverflow
[src]

[src]

Formats the value using the given formatter. Read more

impl PartialEq for WouldOverflow
[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 WouldOverflow
[src]

impl Hash for WouldOverflow
[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 WouldOverflow
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for WouldOverflow

impl Sync for WouldOverflow