Skip to main content

UninitRefMut

Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

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

Source§

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

Implementors§