Slug: borrow-life-03 · Paired reading: Chapter 6
Prompt
fn longest<'a, 'b: 'a>(a: &'a str, b: &'b str) -> &'a str — return
the longer slice. 'b: 'a means "b lives at least as long as a", so a
borrow of either can be typed as &'a str.
The curriculum, drills, tutor, and interviewer mode are for readers of Ace the Rust Interview. The code is printed in the Preface (Companion site access).
Don’t have the book yet? The landing page stays open — purchase unlocks this gym.
beginner · order 33
Slug: borrow-life-03 · Paired reading: Chapter 6
fn longest<'a, 'b: 'a>(a: &'a str, b: &'b str) -> &'a str — return
the longer slice. 'b: 'a means "b lives at least as long as a", so a
borrow of either can be typed as &'a str.