Enter your book access code

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

Outlives bounds in plain English

borrow-life-03Related book chapters: 6 (optional — this page is complete on its own)lifetimeoutlives

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.