Skip to content
Myr

Document anyhow macro 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 5bbb899 · Browse files · 1 file+17 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+17 added−0 removed

  • other:+17 added−0 removed

1 file+17 added−0 removed

modified:src/lib.rs+17 added
290 unmodified lines
291///292/// This evaluates to an `Error`. It can take either just a string, or a format293/// string with arguments. It also can take any custom type which implements294/// `Debug` and `Display`.295///296/// # Example297///298/// ```299/// # type V = ();300/// #301/// use anyhow::{anyhow, Result};302///303/// fn lookup(key: &str) -> Result<V> {304/// if key.len() != 16 {305/// return Err(anyhow!("key length must be 16 characters, got {:?}", key));306/// }307/// 308/// // ...309/// # Ok(())310/// }311/// ```312#[macro_export]313macro_rules! anyhow {314 ($msg:expr $(,)?) => {315 $crate::private::new_adhoc($msg)
28 unmodified lines