Trait SafeArrayPtr

Source
pub unsafe trait SafeArrayPtr<E, L>: BaseArrayPtr<E, L> {
    // Required methods
    fn set_len(&mut self, len: usize);
    fn get_len(&self) -> usize;
}
Expand description

Array pointer that also knows what its length is.

In addition to the invariants discussed in BaseArrayPtr, implementors of this trait need to maintain the following for any instance created via let array = Self::alloc(len):

  • The method array.set_len(len), and only that method, can change the result of array.get_len(), and after calling array.set_len(len), array.get_len() will return the value that was set
  • Any pointer returned by array.get_ptr(i) or array.get_ptr_mut() where i < len points to aligned, allocated memory
  • both array.get_label() and array.get_label_mut() point to allocated, aligned memory as well.

Required Methods§

Source

fn set_len(&mut self, len: usize)

Set the length of this array

Source

fn get_len(&self) -> usize

Get the length of this array

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§