Skip to content

Instantly share code, notes, and snippets.

@kscz
Created April 5, 2016 01:38
Show Gist options
  • Save kscz/7263b1c296f24c000287cd5528012b0f to your computer and use it in GitHub Desktop.
Save kscz/7263b1c296f24c000287cd5528012b0f 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!");
}
fn print_first_return_second<'a, 'b>(print_me: &'a str, return_me: &'b str) -> &'a str {
println!("{}", print_me);
&return_me[4..] // ERROR: we said that the returned reference would be to print_me, but this isn't print_me!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment