pub type Result<T, E = Error> = Result<T, E>;Expand description
Crate-wide result type, defaulting the error to Error.
Handlers and extractors typically return Result<T> (i.e.
Result<T, Error>); the second type parameter exists only so the alias can
be reused with a different error type when desired.
use churust_core::{Error, Result};
use http::StatusCode;
fn parse_age(raw: &str) -> Result<u8> {
raw.parse()
.map_err(|_| Error::bad_request("age must be a number"))
}
assert!(parse_age("30").is_ok());
assert_eq!(parse_age("nope").unwrap_err().status(), StatusCode::BAD_REQUEST);Aliased Type§
pub enum Result<T, E = Error> {
Ok(T),
Err(E),
}