From cbfe2f1de7f0e24525e641228fec4c659badde93 Mon Sep 17 00:00:00 2001 From: Adam Carpenter <53hornet@gmail.com> Date: Fri, 22 Mar 2019 16:48:03 -0400 Subject: Added advanced traits, types, functions. --- advanced/adv-fn-closure/src/main.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 advanced/adv-fn-closure/src/main.rs (limited to 'advanced/adv-fn-closure/src') diff --git a/advanced/adv-fn-closure/src/main.rs b/advanced/adv-fn-closure/src/main.rs new file mode 100644 index 0000000..d31bd90 --- /dev/null +++ b/advanced/adv-fn-closure/src/main.rs @@ -0,0 +1,13 @@ +fn add_one(x: i32) -> i32 { + x + 1 +} + +fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 { + f(arg) + f(arg) +} + +fn main() { + let answer = do_twice(add_one, 5); + + println!("{}", answer); +} -- cgit v1.2.3