summaryrefslogtreecommitdiff
path: root/rust-book/advanced/adv-fn-closure/src/main.rs
blob: 064f300cfa5dd4dd401e2451a82869fd4dc1013c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use hello_macro::HelloMacro;
//use hello_macro_derive::HelloMacro;

struct Pancakes;

impl HelloMacro for Pancakes {
    fn hello_macro() {
        println!("pancakes");
    }
}

fn main() {
    Pancakes::hello_macro();
}

//fn add_one(x: i32) -> i32 {
//    x + 1
//}
//
//fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 {
//    f(arg) + f(arg)
//}


//fn returns_closure() -> Box<dyn Fn(i32) -> i32> {
//    Box::new(|x| x + 1)
//}
//
//
//enum Status {
//    Value(u32),
//    Stop,
//}


//#[macro_export]
//macro_rules! vec {
//    ( $( $x:expr ), * ) => {
//        {
//            let mut temp_vec = Vec::new();
//            $(
//                temp_vec.push($x);
//            )*
//            temp_vec
//        }
//    };
//}


//#[some_attribute]
//pub fn some_name(input: TokenStream) -> TokenStream {
//}
//
//
//fn main() {
//    let answer = do_twice(add_one, 5);
//
//    println!("{}", answer);


//    let list_of_numbers = vec![1, 2, 3];
//    let list_of_strings: Vec<String> = list_of_numbers
//        .iter()
//        .map(ToString::to_string)
//        .collect();
//    dbg!(list_of_strings);


//    let list_of_statuses: Vec<Status> = 
//        (0u32..20)
//        .map(Status::Value)
//        .collect();


    //returns_closure();



//}