test_repo

As usual, I test everything with cats
README | Files | Log | Refs

commit 906b2d4a1bbb65837fff5b1531f8b4ff27f6ca1d
parent ab78ac44325d79fbc634e5dedffe4804d7dbed75
Author: nindwen <me@nindwen.blue>
Date:   Wed,  6 Jun 2018 17:39:23 +0300

function in struct example

Diffstat:
src/main.rs | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -1,8 +1,21 @@ +struct FunktionaalinenKissa<'a> { + command: String, + action: &'a Fn(i32) -> i32, +} // Meows fn miau() -> &'static str { "meow meow" } +fn huu(n: i32) -> i32 { + n*2 +} + fn main() { + let cmd = FunktionaalinenKissa { + command: "moi".to_string(), + action: &huu, + }; println!("Hello, {} world!", miau()); + println!("Hello, {} world times {}!", cmd.command, (cmd.action)(2)); }