mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-10-02 15:26:08 +00:00
Simplify handling of trailing commas
This commit is contained in:
parent
efce155177
commit
17cd390308
10
src/lib.rs
10
src/lib.rs
@ -190,12 +190,9 @@ pub type Result<T> = std::result::Result<T, Error>;
|
|||||||
/// This macro is equivalent to `return Err(From::from($err))`.
|
/// This macro is equivalent to `return Err(From::from($err))`.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! bail {
|
macro_rules! bail {
|
||||||
($err:expr) => {
|
($err:expr $(,)?) => {
|
||||||
return std::result::Result::Err(std::convert::From::from($err));
|
return std::result::Result::Err(std::convert::From::from($err));
|
||||||
};
|
};
|
||||||
($err:expr,) => {
|
|
||||||
$crate::bail!($err);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct an ad-hoc error from a string.
|
/// Construct an ad-hoc error from a string.
|
||||||
@ -205,12 +202,9 @@ macro_rules! bail {
|
|||||||
/// `Debug` and `Display`.
|
/// `Debug` and `Display`.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! anyhow {
|
macro_rules! anyhow {
|
||||||
($msg:expr) => {
|
($msg:expr $(,)?) => {
|
||||||
$crate::private::new_adhoc($msg)
|
$crate::private::new_adhoc($msg)
|
||||||
};
|
};
|
||||||
($msg:expr,) => {
|
|
||||||
$crate::anyhow!($msg)
|
|
||||||
};
|
|
||||||
($fmt:expr, $($arg:tt)*) => {
|
($fmt:expr, $($arg:tt)*) => {
|
||||||
$crate::private::new_adhoc(format!($fmt, $($arg)*))
|
$crate::private::new_adhoc(format!($fmt, $($arg)*))
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user