Skip to content

Instantly share code, notes, and snippets.

@gftea
Last active August 27, 2022 20:07
Show Gist options
  • Save gftea/44ddb45a299958fb3f4070865499aa7e to your computer and use it in GitHub Desktop.
Save gftea/44ddb45a299958fb3f4070865499aa7e to your computer and use it in GitHub Desktop.
#[derive(Debug)]
enum Say {
Hello(String), // == `fn Hello(s: String) -> Say`
Hej(String), // == `fn Hej(s: String) -> Say`
}
fn say(msg: String, f: fn (s: String) -> Say) {
println!("{:?}", f(msg));
}
fn main() {
say("world".to_string(), Say::Hello);
say("sverige".to_string(), Say::Hej);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment