-
-
Save rust-play/7d33cb28590093a0f659e19645cd1878 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
type F = fn(i32) -> i32; | |
fn hoge(v: &mut Vec<F>, f: F) { | |
v.push(f); | |
} | |
fn fuga(i : i32) -> i32 { | |
i + 10 | |
} | |
fn piyo(i: i32) -> i32 { | |
i * 5 | |
} | |
fn main() { | |
let mut v = vec![]; | |
hoge(&mut v, fuga); | |
hoge(&mut v, piyo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment