Guest User

Untitled

a guest
Feb 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. fn main() {
  2. let x = "hi";
  3. let y = "world";
  4. let z = "b".to_string();
  5.  
  6. let res: &'static str = longest(x, y, &z);
  7.  
  8. println!("{}", res);
  9. }
  10.  
  11. // change z to &'b str to make this work
  12. fn longest<'a, 'b>(x: &'a str, y: &'a str, z: &'a str) -> &'a str {
  13. println!("{}", z);
  14. if x.len() > y.len() {
  15. x
  16. } else {
  17. y
  18. }
  19. }
Add Comment
Please, Sign In to add comment