Skip to content
Myr

Simplify handling of trailing commas

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

  • other:+2 added−8 removed

1 file+2 added−8 removed

modified:src/lib.rs+2 added-8 removed
188 unmodified lines
189///190/// This macro is equivalent to `return Err(From::from($err))`.191#[macro_export]192macro_rules! bail {193 ($err:expr) => {193 ($err:expr $(,)?) => {194 return std::result::Result::Err(std::convert::From::from($err));195 };196 ($err:expr,) => {197 $crate::bail!($err);198 };196}197198/// Construct an ad-hoc error from a string.199///
1 unmodified line
201/// string with arguments. It also can take any custom type which implements202/// `Debug` and `Display`.203#[macro_export]204macro_rules! anyhow {208 ($msg:expr) => {205 ($msg:expr $(,)?) => {206 $crate::private::new_adhoc($msg)207 };211 ($msg:expr,) => {212 $crate::anyhow!($msg)213 };208 ($fmt:expr, $($arg:tt)*) => {209 $crate::private::new_adhoc(format!($fmt, $($arg)*))210 };211}
23 unmodified lines