Skip to content
Myr

Accept trailing comma in macros

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 f54adae · Browse files · 1 file+12 added−2 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+12 added−2 removed

  • other:+12 added−2 removed

1 file+12 added−2 removed

modified:src/lib.rs+12 added-2 removed
20 unmodified lines
21macro_rules! bail {22 ($err:expr) => {23 return std::result::Result::Err(std::convert::From::from($err));24 };25 ($err:expr,) => {26 $crate::bail!($err);27 };28}2930/// Construct an ad-hoc error from a string.31///
1 unmodified line
33/// string with arguments. It also can take any custom type which implements34/// `Debug` and `Display`.35#[macro_export]36macro_rules! anyhow {34 ($e:expr) => { $crate::Error::new_adhoc($e) };35 ($($arg:tt)*) => { $crate::Error::new_adhoc(format!($($arg)*)) };37 ($msg:expr) => {38 $crate::Error::new_adhoc($msg)39 };40 ($msg:expr,) => {41 $crate::anyhow!($msg)42 };43 ($fmt:expr, $($arg:tt)*) => {44 $crate::Error::new_adhoc(format!($fmt, $($arg)*))45 };46}