diff options
author | Adam Carpenter <gitlab@53hor.net> | 2019-07-09 15:14:04 -0400 |
---|---|---|
committer | Adam Carpenter <gitlab@53hor.net> | 2019-07-09 15:14:04 -0400 |
commit | 7e8ee5ed9cad6484e9f13f81731b102ced58402e (patch) | |
tree | 5395402ab07bbb5a659dbd68c701e22a1227202f /rust-book/advanced/adv-fn-closure | |
download | learning-rust-7e8ee5ed9cad6484e9f13f81731b102ced58402e.tar.xz learning-rust-7e8ee5ed9cad6484e9f13f81731b102ced58402e.zip |
Init.
Diffstat (limited to 'rust-book/advanced/adv-fn-closure')
-rwxr-xr-x | rust-book/advanced/adv-fn-closure/Cargo.lock | 11 | ||||
-rwxr-xr-x | rust-book/advanced/adv-fn-closure/Cargo.toml | 8 | ||||
-rwxr-xr-x | rust-book/advanced/adv-fn-closure/src/main.rs | 79 |
3 files changed, 98 insertions, 0 deletions
diff --git a/rust-book/advanced/adv-fn-closure/Cargo.lock b/rust-book/advanced/adv-fn-closure/Cargo.lock new file mode 100755 index 0000000..360607c --- /dev/null +++ b/rust-book/advanced/adv-fn-closure/Cargo.lock @@ -0,0 +1,11 @@ +[[package]] +name = "adv-fn-closure" +version = "0.1.0" +dependencies = [ + "hello_macro 0.1.0", +] + +[[package]] +name = "hello_macro" +version = "0.1.0" + diff --git a/rust-book/advanced/adv-fn-closure/Cargo.toml b/rust-book/advanced/adv-fn-closure/Cargo.toml new file mode 100755 index 0000000..6cd8dbd --- /dev/null +++ b/rust-book/advanced/adv-fn-closure/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "adv-fn-closure" +version = "0.1.0" +authors = ["Adam Carpenter <53hornet@gmail.com>"] +edition = "2018" + +[dependencies] +hello_macro = { path = "../hello_macro" } 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<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(); + + + +//} |