test_repo

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

commit 26e1bc354fe86a105e93005079502253db47ce3c
parent 7800a5bc06419255be1410926971f74d9c34c651
Author: nindwen <me@nindwen.blue>
Date:   Wed,  6 Jun 2018 18:09:17 +0300

add call method

Diffstat:
src/main.rs | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -7,15 +7,23 @@ fn miau() -> &'static str { "meow meow" } -fn huu(n: i32) -> i32 { +fn jokin_funktio(n: i32) -> i32 { n*2 } + +impl FunktionaalinenKissa { + fn call(&self, n: i32) -> i32 { + (self.action)(n) + } +} fn main() { let cmd = FunktionaalinenKissa { command: "moi".to_string(), - action: huu, + action: jokin_funktio, }; + println!("Hello, {} world!", miau()); - println!("Hello, {} world times {}!", cmd.command, (cmd.action)(2)); + println!("Hello, {} world times {}!", cmd.command, (cmd.action)(21)); + println!("Hello, {} world times {}!", cmd.command, cmd.call(2)); }