Created
April 23, 2016 17:49
-
-
Save anonymous/d040d644c48a28abc38b1196083cf623 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn get_c() -> Box<FnMut(i32)> { | |
Box::new(|val: i32| { | |
println!("value --> {}", val); | |
}) | |
} | |
pub fn set_c<F>(mut callback: F) | |
where F: FnMut(i32) | |
{ | |
callback(100); | |
} | |
fn main() { | |
let mut cb = get_c(); | |
set_c(|x| cb(x)); | |
set_c(|val: i32| println!("value --> {}", val)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment