#[doc(hidden)] pub unsafe trait TrustedRandomAccessNoCoerce: Sized {
const MAY_HAVE_SIDE_EFFECT: bool;
// Provided method
fn size(&self) -> usize
where Self: Iterator { ... }
}
trusted_random_access
)Expand description
Like TrustedRandomAccess
but without any of the requirements / guarantees around
coercions to supertypes after __iterator_get_unchecked
(they arenโt allowed here!), and
without the requirement that subtypes / supertypes implement TrustedRandomAccessNoCoerce
.
This trait was created in PR #85874 to fix soundness issue #85873 without performance regressions.
It is subject to change as we might want to build a more generally useful (for performance
optimizations) and more sophisticated trait or trait hierarchy that replaces or extends
TrustedRandomAccess
and TrustedRandomAccessNoCoerce
.
Required Associated Constantsยง
Sourceconst MAY_HAVE_SIDE_EFFECT: bool
๐ฌThis is a nightly-only experimental API. (trusted_random_access
)
const MAY_HAVE_SIDE_EFFECT: bool
trusted_random_access
)true
if getting an iterator element may have side effects.
Remember to take inner iterators into account.
Provided Methodsยง
fn size(&self) -> usizewhere
Self: Iterator,
trusted_random_access
)Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.