Created
December 2, 2019 12:13
-
-
Save ficapy/0518381448d707116ee626bf8a5a14d7 to your computer and use it in GitHub Desktop.
This file contains 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
fn apply<F>(mut f: F) | |
where | |
F: FnMut(), | |
{ | |
f(); | |
f(); | |
} | |
fn main() { | |
let mut farewell = "goodbye".to_owned(); | |
let mut diary = move || { | |
farewell.push_str("!!!"); | |
println!("{}.", farewell); | |
}; | |
apply(diary.clone()); | |
apply(&mut diary); | |
apply(diary); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment