Guest User

Untitled

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