From 67cdcc2e12118becb823e20a40cc2687f2b8425a Mon Sep 17 00:00:00 2001 From: Adam Carpenter <53hornet@gmail.com> Date: Wed, 27 Mar 2019 15:32:37 -0400 Subject: Started Rust in Action MEAP. --- rust-book/advanced/adv-fn-closure/src/main.rs | 79 +++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 rust-book/advanced/adv-fn-closure/src/main.rs (limited to 'rust-book/advanced/adv-fn-closure/src') diff --git a/rust-book/advanced/adv-fn-closure/src/main.rs b/rust-book/advanced/adv-fn-closure/src/main.rs new file mode 100755 index 0000000..064f300 --- /dev/null +++ b/rust-book/advanced/adv-fn-closure/src/main.rs @@ -0,0 +1,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 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 = list_of_numbers +// .iter() +// .map(ToString::to_string) +// .collect(); +// dbg!(list_of_strings); + + +// let list_of_statuses: Vec = +// (0u32..20) +// .map(Status::Value) +// .collect(); + + + //returns_closure(); + + + +//} -- cgit v1.2.3