Skip to content

Instantly share code, notes, and snippets.

@eduardonunesp
Created January 4, 2022 16:27
Show Gist options
  • Save eduardonunesp/dcb680e17d7d576b2fb0acdb402d5be2 to your computer and use it in GitHub Desktop.
Save eduardonunesp/dcb680e17d7d576b2fb0acdb402d5be2 to your computer and use it in GitHub Desktop.
type CbFunc = fn();
fn main() {
call_func(print_hello);
call_func(|| println!("{}", "haloo :D")); // Closure
}
fn call_func(f: CbFunc) {
f();
}
fn print_hello() {
println!("Hello, world!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment