Quiz · Lifetimes · lesson 3 of 6
Quiz — the shorter borrow
What happens when this program is built and run?
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() >= y.len() { x } else { y }
}
fn main() {
let a = String::from("long string");
let result = {
let b = String::from("xyz");
longest(&a, &b)
};
println!("{result}");
}