{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiatablhnrbnbqd2abg6mniqvywheghhg2sekave6a6y7hyvznh66u",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mhafuyvxp2h2"
},
"path": "/t/private-lifetime-inference/24088#post_4",
"publishedAt": "2026-03-16T21:26:36.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"Playground"
],
"textContent": "redradist:\n\n> **Closures already do this.** `|x: &str, y: &str| -> &str { x }` infers lifetimes from the body.\n\nDoes it?\n\n\n error: lifetime may not live long enough\n --> src/main.rs:2:34\n |\n 2 | |x: &str, y: &str| -> &str { x };\n | - - ^ returning this value requires that `'1` must outlive `'2`\n | | |\n | | let's call the lifetime of this reference `'2`\n | let's call the lifetime of this reference `'1`\n\n\nPlayground",
"title": "Private lifetime inference"
}