AnyResult

Type Alias AnyResult 

pub type AnyResult<T> = Result<T, AnyError>;
Available on crate feature error only.
Expand description

A Result using AnyError as the error type.

This is slightly different from anyhow’s approach, which only sets a default value for the error type. It could be argued that this is more convenient since you can import anyhow::Result and use it for all cases. There are downsides to this approach, though:

  • It can lead to type inference issues in some cases.
  • It can be confusing when reading code. Result is a fundamental type and shadowing it can make it harder to understand what is going on.

That’s why we instead call this type AnyResult and fix the error type.

Aliased Type§

pub enum AnyResult<T> {
    Ok(T),
    Err(Error),
}

Variants§

§1.0.0

Ok(T)

Contains the success value

§1.0.0

Err(Error)

Contains the error value