Created
April 5, 2016 01:42
-
-
Save kscz/689a9750f24b03f8eca001e418699ac5 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
fn main() { | |
println!("Hello darkness my old {}", pick_one(true, "friend", "frenemy")); | |
println!("I've come to {} with you again.", pick_one(false, "dance", "talk")); | |
println!("Because a {} softly creeping", pick_one(false, "gremlin", "vision")); | |
println!("Left its {} while I was {}.", pick_one(true, "seeds", "cell phone"), pick_one(false, "also creeping", "sleeping")); | |
} | |
// ERROR: rust doesn't know which lifetime to pick! This or that? | |
fn pick_one(this_or_that: bool, this: &str, that: &str) -> &str { | |
if this_or_that { | |
this | |
} else { | |
that | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment