Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created November 26, 2021 05:14
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/7d33cb28590093a0f659e19645cd1878 to your computer and use it in GitHub Desktop.
Save rust-play/7d33cb28590093a0f659e19645cd1878 to your computer and use it in GitHub Desktop.
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