summaryrefslogtreecommitdiff
path: root/advanced/adv-fn-closure/src/main.rs
diff options
context:
space:
mode:
authorAdam Carpenter <53hornet@gmail.com>2019-03-26 15:05:10 -0400
committerAdam Carpenter <53hornet@gmail.com>2019-03-26 15:05:10 -0400
commit5718a0b54869b341bc74416bf82b716aa15d582c (patch)
tree0a1ab65ecc854733c15011f364524bde8379ae1b /advanced/adv-fn-closure/src/main.rs
parent29db8e4c4182877e5e723e26e2c5ae11e9383520 (diff)
downloadlearning-rust-5718a0b54869b341bc74416bf82b716aa15d582c.tar.xz
learning-rust-5718a0b54869b341bc74416bf82b716aa15d582c.zip
Finished web server project. Book done!
Diffstat (limited to 'advanced/adv-fn-closure/src/main.rs')
-rw-r--r--advanced/adv-fn-closure/src/main.rs82
1 files changed, 74 insertions, 8 deletions
diff --git a/advanced/adv-fn-closure/src/main.rs b/advanced/adv-fn-closure/src/main.rs
index d31bd90..064f300 100644
--- a/advanced/adv-fn-closure/src/main.rs
+++ b/advanced/adv-fn-closure/src/main.rs
@@ -1,13 +1,79 @@
-fn add_one(x: i32) -> i32 {
- x + 1
-}
+use hello_macro::HelloMacro;
+//use hello_macro_derive::HelloMacro;
+
+struct Pancakes;
-fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 {
- f(arg) + f(arg)
+impl HelloMacro for Pancakes {
+ fn hello_macro() {
+ println!("pancakes");
+ }
}
fn main() {
- let answer = do_twice(add_one, 5);
-
- println!("{}", answer);
+ 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();
+
+
+
+//}