Skip to content

Instantly share code, notes, and snippets.

@bstrie
Forked from insaneinside/Cargo.toml
Created March 21, 2015 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bstrie/653bc834aa871b8f45fa to your computer and use it in GitHub Desktop.
Save bstrie/653bc834aa871b8f45fa to your computer and use it in GitHub Desktop.
[package]
name="bob"
version="0.0.1"
authors=["insaneinside"]
[lib]
name="bob"
path="lib.rs"
/// 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