Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created November 25, 2021 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/8121c9afb99fc74b7a67716f3ed38d83 to your computer and use it in GitHub Desktop.
Save rust-play/8121c9afb99fc74b7a67716f3ed38d83 to your computer and use it in GitHub Desktop.
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