-
-
Save rust-play/0c50feb83babb4df431f7d18afa85ca8 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains 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 hoge(x: i32) -> i32 { | |
x + 1 | |
} | |
fn fuga(y: i32) -> i32 { | |
y * 2 | |
} | |
fn main() { | |
let mut f: Box<dyn Fn(i32) -> i32> = Box::new(hoge); | |
println!("{}", f(15)); | |
f = Box::new(fuga); | |
println!("{}", f(20)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment