{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreicjxsa5kkxx5dz6bczf3z7tk4djgtwh27d7mqpmrr22uozsi5jsty",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mmu7abkvl232"
},
"path": "/t/pre-rfc-unsafe-traits-conditionally-depending-on-safe-trait-behaviour/24360#post_4",
"publishedAt": "2026-05-27T16:43:13.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "Conceptually, at least, it does seem like it'd be nice to have something like this.\n\nFor example, `TrustedLen` wants to also put a requirement that `ExactSizeIterator::len` can't be garbage, but there's nothing on that trait impl (nor the `len` method) itself that acknowledges that.\n\n* * *\n\nSpitballing, this seems awkward:\n\nnia-e:\n\n>\n> #[unsafe(has_preconditions(Allocator))]\n> trait Clone {}\n>\n\nbecause `Clone` is in `core` so if something that's not `core` -- such as external crates, if this wanted to become a \"real\" feature -- then they _can't_ put something on `Clone`.",
"title": "Pre-RFC: Unsafe traits conditionally depending on safe trait behaviour"
}