pub struct UncheckedIndexing;Expand description
Unchecked indexing strategy for sequences.
In this mode, the Seq<T> includes only the storage
for the T objects, and nothing else. It is not possible to check integer offsets for
validity in this mode, so only unsafe unchecked indexing is available.
§Examples
use varlen::prelude::*;
let mut seq = Seq::new_minimal();
seq.push(Str::copy("hello"));
let pos = seq.offset();
seq.push(Str::copy("world"));
// Safe because: first element is always at offset 0.
assert_eq!("hello", unsafe { &seq.from_offset_unchecked(0)[..] });
// Safe because: offset() returned offset of the next element to be pushed.
assert_eq!("world", unsafe { &seq.from_offset_unchecked(pos)[..] });Trait Implementations§
impl Indexing for UncheckedIndexing
Auto Trait Implementations§
impl Freeze for UncheckedIndexing
impl RefUnwindSafe for UncheckedIndexing
impl Send for UncheckedIndexing
impl Sync for UncheckedIndexing
impl Unpin for UncheckedIndexing
impl UnsafeUnpin for UncheckedIndexing
impl UnwindSafe for UncheckedIndexing
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more