Result

Type Alias Result 

Source
pub type Result<T, C> = Result<T, Report<C>>;
👎Deprecated since 0.6.0: Use core::result::Result<T, Report<C>> instead
Expand description

Result<T, Report>

A reasonable return type to use throughout an application.

The Result type can be used with one or two parameters, where the first parameter represents the Ok arm and the second parameter Error is used as in Report<C>.

§Examples

Result can also be used in fn main():

use error_stack::{ensure, Report};

fn main() -> Result<(), Report<AccessError>> {
    let user = get_user()?;
    let resource = get_resource()?;

    ensure!(
        has_permission(user, resource),
        AccessError::PermissionDenied(user, resource)
    );

    ...
}

Aliased Type§

pub enum Result<T, C> {
    Ok(T),
    Err(Report<C>),
}

Variants§

§1.0.0

Ok(T)

Contains the success value

§1.0.0

Err(Report<C>)

Contains the error value