Type Alias ResultStack

Source
pub type ResultStack<T, C = dyn Error> = Result<T, Report<C>>;
Expand description

Result<T, Error>

This is a reasonable return type to use throughout your application.

anystack::ResultStack may be used with one or two type parameters.

fn demo1() -> anystack::ResultStack<T> {...}
           // ^ equivalent to:
           // std::result::Result<T, anystack::Report<dyn core::error::Error>>

fn demo2() -> anystack::ResultStack<T, OtherError> {...}
           // ^ equivalent to:
           // std::result::Result<T, anystack::Report<OtherError>>

§Example

use anystack::ResultStack;

fn main() -> ResultStack<()> {
    let config = std::fs::read_to_string("cluster.json")?;
    let map: ClusterMap = serde_json::from_str(&config)?;
    println!("cluster info: {:#?}", map);
    Ok(())
}

Aliased Type§

pub enum ResultStack<T, C = dyn Error> {
    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