{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreia4z7ggwdjkm2hsfhz7u5nowrdk36vjclz7ztq7q733q7zkvps4ui",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mlehoynppdo2"
  },
  "path": "/t/pre-rfc-peeking-from-peekable-with-less-unwrapping/24169#post_5",
  "publishedAt": "2026-05-08T19:24:10.000Z",
  "site": "https://internals.rust-lang.org",
  "textContent": "Your code is unsound. You have to forbid keeping the reference returned by `get` when consume is called:\n\n\n        let mut it = vec![String::from(\"hello\")].into_iter().peekable();\n        let p = Peeked::peek_from(&mut it).unwrap();\n        let r: &String = p.get();\n        let owned: String = p.consume(); // moves the String\n        drop(owned);\n        println!(\"{r}\"); // r is a stale reference\n",
  "title": "[Pre-RFC] Peeking from Peekable with less unwrapping"
}