Trait UnsafeIndex

Source
pub trait UnsafeIndex<Idx> {
    type Output;

    // Required methods
    unsafe fn unsafe_index(&self, index: Idx) -> &Self::Output;
    unsafe fn unsafe_index_mut(&self, index: Idx) -> &mut Self::Output;
}
Expand description

Unsafe Index trait.

Like Index, performs checked indexing, but the caller must ensure that there is no aliasing of a mutable reference.

Required Associated Types§

Source

type Output

The returned type after indexing.

Required Methods§

Source

unsafe fn unsafe_index(&self, index: Idx) -> &Self::Output

Immutably indexes with index.

§Safety

The caller must ensure that the returned reference is not aliased by a mutable borrow, ie by a call to .unsafe_index_mut() with the same index.

Source

unsafe fn unsafe_index_mut(&self, index: Idx) -> &mut Self::Output

Mutably indexes with index.

§Safety

The caller must ensure that the returned reference is not aliased by another borrow, ie by a call to .unsafe_index() or .unsafe_index_mut() with the same index.

Implementors§