Skip to content
Myr

Implement 1-argument ensure

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 0c0e41f · Browse files · 1 file+3 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+3 added−0 removed

  • other:+3 added−0 removed

1 file+3 added−0 removed

modified:src/macros.rs+3 added
111 unmodified lines
112/// # }113/// ```114#[macro_export]115macro_rules! ensure {116 ($cond:expr $(,)?) => {117 $crate::ensure!($cond, concat!("Condition failed: `", stringify!($cond), "`"))118 };119 ($cond:expr, $msg:literal $(,)?) => {120 if !$cond {121 return $crate::private::Err($crate::anyhow!($msg));122 }
57 unmodified lines