Created
April 5, 2016 01:38
-
-
Save kscz/7263b1c296f24c000287cd5528012b0f 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() { | |
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