Skip to content

Instantly share code, notes, and snippets.

@kscz
Created April 5, 2016 01:43
Show Gist options
  • Save kscz/7543754b36cf5995cbf54d4e14b28b6b to your computer and use it in GitHub Desktop.
Save kscz/7543754b36cf5995cbf54d4e14b28b6b to your computer and use it in GitHub Desktop.
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"));
}
fn pick_one<'a>(this_or_that: bool, this: &'a str, that: &'a str) -> &'a 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