Type Alias zellij_utils::errors::prelude::Result
source · pub type Result<T, E = Error> = Result<T, E>;
Expand description
Result<T, Error>
This is a reasonable return type to use throughout your application but also
for fn main
; if you do, failures will be printed along with any
context and a backtrace if one was captured.
anyhow::Result
may be used with one or two type parameters.
use anyhow::Result;
fn demo1() -> Result<T> {...}
// ^ equivalent to std::result::Result<T, anyhow::Error>
fn demo2() -> Result<T, OtherError> {...}
// ^ equivalent to std::result::Result<T, OtherError>
§Example
use anyhow::Result;
fn main() -> Result<()> {
let config = std::fs::read_to_string("cluster.json")?;
let map: ClusterMap = serde_json::from_str(&config)?;
println!("cluster info: {:#?}", map);
Ok(())
}
Aliased Type§
enum Result<T, E = Error> {
Ok(T),
Err(E),
}
Variants§
Trait Implementations§
source§impl<T> FatalError<T> for Result<T>
impl<T> FatalError<T> for Result<T>
source§impl<T> LoggableError<T> for Result<T>
impl<T> LoggableError<T> for Result<T>
source§fn print_error<F: Fn(&str)>(self, fun: F) -> Self
fn print_error<F: Fn(&str)>(self, fun: F) -> Self
Gives a formatted error message derived from
self
to the closure fun
for
printing/logging as appropriate. Read moresource§fn to_log(self) -> Self
fn to_log(self) -> Self
Convenienve function, calls
print_error
and logs the result as error. Read more