{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreid5bm4sjrggvojzgtvsmwx43pokxpfngnaum5ssmqvmqk2gx2tmne",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mjducxvsv4w2"
  },
  "path": "/t/pre-rfc-peeking-from-peekable-with-less-unwrapping/24169#post_4",
  "publishedAt": "2026-04-13T01:53:04.000Z",
  "site": "https://internals.rust-lang.org",
  "textContent": "You can implement this without `unwrap` by comparing the `Option`s `a.peek()` and `b.peek()` to decide which of the iterators to return the value of `next()` from. (Note that you will need to use a comparison that sorts `Some` before `None` and low `Some` before high `Some`, which I don't think is built-in in `Option`, but it is easy enough to implement.) This avoids unwrapping because all you're doing is deciding which iterator to iterate on, and if you're taking a value from an empty iterator it is because both are exhausted, so you can return the `None` you get directly.\n\nI'm not sure whether or not this technique generalises, but it is at least pretty good for iterator adaptors (and might generate simpler code than you get with `Peeked`).",
  "title": "[Pre-RFC] Peeking from Peekable with less unwrapping"
}