Trait tea_core::prelude::UninitRefMut

source ·
pub trait UninitRefMut<T>: GetLen {
    // Required method
    unsafe fn uset(&mut self, idx: usize, v: T);

    // Provided method
    fn write_trust_iter<I: TrustedLen<Item = T>>(
        &mut self,
        iter: I,
    ) -> TResult<()>
       where T: Clone { ... }
}
Expand description

Trait for mutable references to uninitialized vectors that can be written to.

Required Methods§

source

unsafe fn uset(&mut self, idx: usize, v: T)

Sets the value at the given index in the uninitialized vector.

§Safety

The caller should ensure that the index is less than the length of the array.

Provided Methods§

source

fn write_trust_iter<I: TrustedLen<Item = T>>(&mut self, iter: I) -> TResult<()>
where T: Clone,

Writes the contents of a trusted iterator to the uninitialized vector.

This method handles three cases:

  1. If the iterator length matches the vector length, it writes each item.
  2. If the iterator has only one item, it clones and writes that item to all positions.
  3. If the lengths don’t match and the iterator has more than one item, it returns an error.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> UninitRefMut<T> for &mut [MaybeUninit<T>]

source§

unsafe fn uset(&mut self, idx: usize, v: T)

Implementors§