Last active
August 27, 2022 20:07
-
-
Save gftea/44ddb45a299958fb3f4070865499aa7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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