mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-05 10:19:18 +00:00
Refactor longest function to use lifetimes
This commit is contained in:
parent
b3fbab1791
commit
f996183355
@ -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 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user