-
-
Save bstrie/653bc834aa871b8f45fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name="bob" | |
version="0.0.1" | |
authors=["insaneinside"] | |
[lib] | |
name="bob" | |
path="lib.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Panic with a given message unless an expression evaluates to true. | |
/// | |
/// ## Examples | |
/// ```rust | |
/// #[macro_use] extern crate bob; | |
/// fn main() { | |
/// panic_unless!(1 + 1 == 2, "Math is broken."); | |
/// } | |
/// ``` | |
/// | |
/// ```rust,should_fail | |
/// #[macro_use] extern crate bob; | |
/// fn main() { | |
/// panic_unless!(true == false, "I'm broken."); | |
/// } | |
/// ``` | |
#[macro_export] | |
macro_rules! panic_unless { | |
($condition:expr, $($rest:expr),+) => ({ if ! $condition { panic!($($rest),+); } }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment