Transfer

Trait Transfer 

Source
pub unsafe trait Transfer<T> {
    // Required methods
    fn len(&self) -> usize;
    unsafe fn transfer(self, len: usize, dst: *mut T);
}
Expand description

Types that may be passed to append.

This trait is implemented on collections that coerce into a slice ([T] or &[T] where T: Copy), which notably don’t include most iterator adapters. This is because append requires all transfer operations to not diverge (e.g. panic!(..)), otherwise the fragment slice may end up with uninitialized memory which will lead to undefined behavior when used or even dropped.

§Safety

  • len must return precisely how much elements this slice will copy. In particular, the returned value will by passed to transfer.
  • transfer must write exactly len initialized elements to dst, and must not diverge.

Required Methods§

Source

fn len(&self) -> usize

Returns the length of the slice.

Source

unsafe fn transfer(self, len: usize, dst: *mut T)

Transfer contents of this slice into the destination pointer.

§Safety
  • len must be the same as what len returns.
  • dst must be a pointer valid for writing len elements, and must not overlap this slice.

Implementations on Foreign Types§

Source§

impl<T> Transfer<T> for Box<[T]>

Source§

fn len(&self) -> usize

Source§

unsafe fn transfer(self, len: usize, dst: *mut T)

Source§

impl<T> Transfer<T> for Drain<'_, T>

Source§

fn len(&self) -> usize

Source§

unsafe fn transfer(self, len: usize, dst: *mut T)

Source§

impl<T> Transfer<T> for IntoIter<T>

Source§

fn len(&self) -> usize

Source§

unsafe fn transfer(self, len: usize, dst: *mut T)

Source§

impl<T> Transfer<T> for Vec<T>

Source§

fn len(&self) -> usize

Source§

unsafe fn transfer(self, len: usize, dst: *mut T)

Source§

impl<T, const LEN: usize> Transfer<T> for [T; LEN]

Source§

fn len(&self) -> usize

Source§

unsafe fn transfer(self, len: usize, dst: *mut T)

Source§

impl<T, const LEN: usize> Transfer<T> for IntoIter<T, LEN>

Source§

fn len(&self) -> usize

Source§

unsafe fn transfer(self, len: usize, dst: *mut T)

Source§

impl<T: Copy> Transfer<T> for &[T]

Source§

fn len(&self) -> usize

Source§

unsafe fn transfer(self, len: usize, dst: *mut T)

Source§

impl<T: Copy> Transfer<T> for Iter<'_, T>

Source§

fn len(&self) -> usize

Source§

unsafe fn transfer(self, len: usize, dst: *mut T)

Implementors§