pub unsafe trait TrustedRandomAccessNoCoerce: Sized {
    const MAY_HAVE_SIDE_EFFECT: bool;

    // Provided method
    fn size(&self) -> usize
       where Self: Iterator { ... }
}
🔬This is a nightly-only experimental API. (trusted_random_access)
Expand description

Like TrustedRandomAccess but without any of the requirements / guarantees around coercions to subtypes 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§

source

const MAY_HAVE_SIDE_EFFECT: bool

🔬This is a nightly-only experimental API. (trusted_random_access)

true if getting an iterator element may have side effects. Remember to take inner iterators into account.

Provided Methods§

source

fn size(&self) -> usizewhere Self: Iterator,

🔬This is a nightly-only experimental API. (trusted_random_access)

Implementors§