Mercurial > lbo > hg > lazycall
view examples/test_functions.rs @ 1:babb2f9cb5ad
All features working
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Fri, 20 Nov 2020 23:20:03 +0100 |
parents | 7401c615042c |
children | 2b71ed370156 |
line wrap: on
line source
use lazycall::{lazy, lazycall}; #[lazy] fn test_function_empty() -> i32 { 3 } struct TestStruct(i32); #[lazy] fn test_function_someargs(a: i32, b: usize, c: TestStruct) -> bool { a%2 == 0 } #[lazy] fn test_function_onearg(a: i32) -> bool { a%2 == 0 } impl TestStruct { #[lazy] fn test_receiving_func(&self, a: i32) -> bool { (self.0+a)%2 == 0 } } fn main() { println!("{}", test_function_onearg(32));; println!("lazy: {}", lazycall!(test_function_onearg(32))); let mystruct = TestStruct(32); println!("{}", mystruct.test_receiving_func(33)); println!("lazy: {}", lazycall!(mystruct.test_receiving_func(33))); }