study_example/advance_feature/
macros.rs1#[macro_export] macro_rules! vecs {
3 ( $( $x:expr ),* ) => { {
6 let mut temp_vec = Vec::new();
7 $(
8 temp_vec.push($x);
9 )*
10 temp_vec
11 }
12 };
13}
14
15pub trait HelloMacro {
19 fn hello_macro();
20}
21
22struct Pancakes;
23
24impl HelloMacro for Pancakes {
25 fn hello_macro() {
26 println!("Hello macro! My name is Pancakes.");
27 }
28}
29
30use hello_macro_derive::*;
31#[derive(HelloMacro)]
34struct Pancakes2;
35
36pub fn macros_study() {
43 let vec_val = vecs![12, 34, 56, 98];
44 println!("{:?}", vec_val);
45 Pancakes::hello_macro();
46 Pancakes2::hello_macro();
47}