Refactor longest function to use lifetimes

This commit is contained in:
Rock070 2024-01-05 00:28:10 +08:00
parent b3fbab1791
commit f996183355

View File

@ -8,9 +8,7 @@
// Execute `rustlings hint lifetimes1` or use the `hint` watch subcommand for a // Execute `rustlings hint lifetimes1` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
fn longest(x: &str, y: &str) -> &str {
if x.len() > y.len() { if x.len() > y.len() {
x x
} else { } else {