Skip to content
Myr

Document anyhow::Result with example

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 55181d5 · Browse files · 1 file+30 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+30 added−0 removed

  • other:+30 added−0 removed

1 file+30 added−0 removed

modified:src/lib.rs+30 added
182 unmodified lines
183pub use crate::context::Context;184pub use crate::error::{Chain, Error};185186/// `Result<T, Error>`187///188/// # Example189///190/// ```191/// # pub trait Deserialize {}192/// #193/// # mod serde_json {194/// # use super::Deserialize;195/// # use std::io;196/// #197/// # pub fn from_str<T: Deserialize>(json: &str) -> io::Result<T> {198/// # unimplemented!()199/// # }200/// # }201/// #202/// # #[derive(Debug)]203/// # struct ClusterMap;204/// #205/// # impl Deserialize for ClusterMap {}206/// #207/// use anyhow::Result;208///209/// fn main() -> Result<()> {210/// # return Ok(());211/// let config = std::fs::read_to_string("cluster.json")?;212/// let map: ClusterMap = serde_json::from_str(&config)?;213/// println!("cluster info: {:#?}", map);214/// Ok(())215/// }216/// ```217pub type Result<T> = std::result::Result<T, Error>;218219/// Return early with an error.220///
45 unmodified lines