Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created Nov 26, 2021
Embed
What would you like to do?
Code shared from the Rust Playground
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