Trait coded::ResultExt[][src]

pub trait ResultExt<T, E> {
    fn err_kind<K: Into<ErrorKind>>(self, k: K) -> Result<T, ErrorBuilder>
    where
        E: StdError + 'static
; fn err_unknown(self) -> Result<T, ErrorBuilder>
    where
        Self: Sized,
        E: StdError + 'static
, { ... } }
Expand description

Extension methods for Result.

Required methods

Builds an Error with the given kind, and the original error as source.

Example:

use coded::{Error, ErrorKind, ResultExt};
use std::io::Read;
fn foo() -> Result<(), Error> {
    let mut buf = [0u8; 1];
    std::io::Cursor::new("").read_exact(&mut buf[..]).err_kind(ErrorKind::Internal)?;
    Ok(())
}
assert_eq!(foo().unwrap_err().kind(), coded::ErrorKind::Internal);

Provided methods

Shorthand for err_kind(ErrorKind::Unknown).

Implementations on Foreign Types

Wraps errors using the given kind.

Implementors