Skip to content

Instantly share code, notes, and snippets.

@kscz
Created April 5, 2016 01:35
Show Gist options
  • Save kscz/a12ae014a9e51aad4679245ef7850df5 to your computer and use it in GitHub Desktop.
Save kscz/a12ae014a9e51aad4679245ef7850df5 to your computer and use it in GitHub Desktop.
fn main() {
let x = String::from("What is love?");
let y = String::from("Baby don't hurt me,");
let ref_y = print_first_return_second(&x, &y);
print!("{}", y);
print!("{}", ref_y);
println!(" no more.");
}
// ERROR: I can't figure out if the returned value is a reference to "print_me" or "return_me"!
fn print_first_return_second(print_me: &str, return_me: &str) -> &str {
println!("{}", print_me);
&return_me[4..]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment