rust-book/hello_macro/src/lib.rs

21 lines
423 B
Rust
Raw Normal View History

2019-02-11 10:14:27 -05:00
pub trait HelloMacro {
fn hello_macro();
}
/// Simplified version of the vec! macro
/// This is an example of a declarative macro
#[macro_export] // This makes the macro usable
macro_rules! vec {
( $( $x:expr ),* ) => { // This matches the argument list
{
let mut temp_vec = Vec::new();
$(
temp_vec.push($x);
)*
temp_vec
}
};
}