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 2

Who owns the return value?

own-move-02Related book chapters: 5 (optional — this page is complete on its own)ownershipmovefunction

Slug: own-move-02 · Paired reading: Chapter 5

Prompt

Implement fn greet(name: &str) -> String that returns "hello, {name}". The input is borrowed; the output is owned. Say aloud why that split is load-bearing.

Predict first

Could this return &str pointing into a local String? What error fires?