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 ofarray.get_len()
, and after callingarray.set_len(len)
,array.get_len()
will return the value that was set - Any pointer returned by
array.get_ptr(i)
orarray.get_ptr_mut()
wherei < len
points to aligned, allocated memory - both
array.get_label()
andarray.get_label_mut()
point to allocated, aligned memory as well.
Required Methods§
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.