Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created Nov 25, 2021
Embed
What would you like to do?
Code shared from the Rust Playground
fn add<F>(v: &mut Vec<F>, f: F) {
v.push(f);
}
fn hoge(i: i32) -> i32 {
i + 1
}
fn fuga(i: i32) -> i32 {
i * 2
}
fn main() {
let mut v = vec![];
add(&mut v, hoge);
add(&mut v, fuga);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment