Trait cl_generic_vec::raw::Storage[][src]

pub unsafe trait Storage<T> {
    const IS_ALIGNED: bool;

    fn capacity(&self) -> usize;
fn as_ptr(&self) -> *const T;
fn as_mut_ptr(&mut self) -> *mut T;
fn reserve(&mut self, new_capacity: usize);
fn try_reserve(&mut self, new_capacity: usize) -> bool; }
Expand description

A type that can hold Ts, and potentially reserve space for more Self::Itemss

Safety

Other safe types rely on this trait being implemented correctly. See the safety requirements on each function

Associated Constants

Is the pointer from as_ptr guaranteed to be aligned to T

Ideally this would be a where clause to prevent alignment issues at compile time, but that can’t happen until const-generics allows predicates in where bounds (like where align_of::<T>() >= align_of::<U>())

Required methods

The number of elements that it is valid to write to this Storage

i.e. as_mut_ptr()..as_mut_ptr() + capacity() should be valid to write Ts

Returns a pointer to the first element

Returns a mutable pointer to the first element

Reserves space for at least new_capacity elements

Safety

After this call successfully ends, the capacity must be at least new_capacity

Panic/Abort

Maybe panic or abort if it is impossible to set the capacity to at least new_capacity

Tries to reserve space for at least new_capacity elements

Returns Ok(()) on success, Err(AllocError) if it is impossible to set the capacity to at least new_capacity

Safety

If Ok(()) is returned, the capacity must be at least new_capacity

Implementations on Foreign Types

Implementors