Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let x = "hi";
- let y = "world";
- let z = "b".to_string();
- let res: &'static str = longest(x, y, &z);
- println!("{}", res);
- }
- // change z to &'b str to make this work
- fn longest<'a, 'b>(x: &'a str, y: &'a str, z: &'a str) -> &'a str {
- println!("{}", z);
- if x.len() > y.len() {
- x
- } else {
- y
- }
- }
Add Comment
Please, Sign In to add comment