Trait AllocSliceExt

Source
pub trait AllocSliceExt: AllocSlice + AllocExt {
    // Provided methods
    fn alloc_slice_filled<T>(
        &self,
        len: usize,
        n: u8,
    ) -> Result<NonNull<[T]>, AllocError> { ... }
    fn alloc_slice_patterned<T, F: Fn(usize) -> u8 + Clone>(
        &self,
        len: usize,
        pattern: F,
    ) -> Result<NonNull<[T]>, AllocError> { ... }
    unsafe fn grow_slice_filled<T>(
        &self,
        slice: NonNull<[T]>,
        new_len: usize,
        n: u8,
    ) -> Result<NonNull<[T]>, AllocError> { ... }
    unsafe fn grow_raw_slice_filled<T>(
        &self,
        ptr: NonNull<T>,
        len: usize,
        new_len: usize,
        n: u8,
    ) -> Result<NonNull<T>, AllocError> { ... }
    unsafe fn grow_slice_patterned<T, F: Fn(usize) -> u8 + Clone>(
        &self,
        slice: NonNull<[T]>,
        new_len: usize,
        pattern: F,
    ) -> Result<NonNull<[T]>, AllocError> { ... }
    unsafe fn grow_raw_slice_patterned<T, F: Fn(usize) -> u8 + Clone>(
        &self,
        ptr: NonNull<T>,
        len: usize,
        new_len: usize,
        pattern: F,
    ) -> Result<NonNull<T>, AllocError> { ... }
    unsafe fn realloc_slice_filled<T>(
        &self,
        slice: NonNull<[T]>,
        new_len: usize,
        n: u8,
    ) -> Result<NonNull<[T]>, AllocError> { ... }
    unsafe fn realloc_raw_slice_filled<T>(
        &self,
        ptr: NonNull<T>,
        len: usize,
        new_len: usize,
        n: u8,
    ) -> Result<NonNull<T>, AllocError> { ... }
    unsafe fn realloc_slice_patterned<T, F: Fn(usize) -> u8 + Clone>(
        &self,
        slice: NonNull<[T]>,
        new_len: usize,
        pattern: F,
    ) -> Result<NonNull<[T]>, AllocError> { ... }
    unsafe fn realloc_raw_slice_patterned<T, F: Fn(usize) -> u8 + Clone>(
        &self,
        ptr: NonNull<T>,
        len: usize,
        new_len: usize,
        pattern: F,
    ) -> Result<NonNull<T>, AllocError> { ... }
}
Expand description

Slice-specific extension methods for AllocExt, providing extended convenient functions for slice allocator operations.

Provided Methods§

Source

fn alloc_slice_filled<T>( &self, len: usize, n: u8, ) -> Result<NonNull<[T]>, AllocError>

Attempts to allocate a block of memory for len instances of T, filled with bytes initialized to n.

§Errors
Source

fn alloc_slice_patterned<T, F: Fn(usize) -> u8 + Clone>( &self, len: usize, pattern: F, ) -> Result<NonNull<[T]>, AllocError>

Attempts to allocate a block of memory for len instances of T and fill it by calling pattern(i) for each byte index i.

§Errors
Source

unsafe fn grow_slice_filled<T>( &self, slice: NonNull<[T]>, new_len: usize, n: u8, ) -> Result<NonNull<[T]>, AllocError>

Grows a slice to a new length, filling any newly allocated bytes with n.

§Errors
§Safety
  • slice must point to a slice allocated using this allocator.
Source

unsafe fn grow_raw_slice_filled<T>( &self, ptr: NonNull<T>, len: usize, new_len: usize, n: u8, ) -> Result<NonNull<T>, AllocError>

Grows a slice to a new length given the pointer to its first element, current length, and requested length, filling any newly allocated bytes with n.

§Errors
§Safety
  • ptr must point to a slice allocated using this allocator.
  • len must describe exactly the number of elements in that slice.
Source

unsafe fn grow_slice_patterned<T, F: Fn(usize) -> u8 + Clone>( &self, slice: NonNull<[T]>, new_len: usize, pattern: F, ) -> Result<NonNull<[T]>, AllocError>

Grows a slice to a new length, filling any newly allocated bytes by calling pattern(i) for each new byte index i.

§Errors
§Safety
  • slice must point to a slice allocated using this allocator.
Source

unsafe fn grow_raw_slice_patterned<T, F: Fn(usize) -> u8 + Clone>( &self, ptr: NonNull<T>, len: usize, new_len: usize, pattern: F, ) -> Result<NonNull<T>, AllocError>

Grows a slice to a new length given the pointer to its first element, current length, and requested length, filling any newly allocated bytes by calling pattern(i) for each new byte index i.

§Errors
§Safety
  • ptr must point to a slice allocated using this allocator.
  • len must describe exactly the number of elements in that slice.
Source

unsafe fn realloc_slice_filled<T>( &self, slice: NonNull<[T]>, new_len: usize, n: u8, ) -> Result<NonNull<[T]>, AllocError>

Reallocates a slice to a new length, filling any newly allocated bytes with n.

On grow, preserves all existing elements and truncates to new_len elements on shrink.

§Errors
§Safety
  • slice must point to a slice allocated using this allocator.
Source

unsafe fn realloc_raw_slice_filled<T>( &self, ptr: NonNull<T>, len: usize, new_len: usize, n: u8, ) -> Result<NonNull<T>, AllocError>

Reallocates a slice to a new length given the pointer to its first element, current length, and requested length, filling any newly allocated bytes with n.

On grow, preserves all existing elements and truncates to new_len elements on shrink.

§Errors
§Safety
  • ptr must point to a slice allocated using this allocator.
  • len must describe exactly the number of elements in that slice.
Source

unsafe fn realloc_slice_patterned<T, F: Fn(usize) -> u8 + Clone>( &self, slice: NonNull<[T]>, new_len: usize, pattern: F, ) -> Result<NonNull<[T]>, AllocError>

Reallocates a slice to a new length, filling any newly allocated bytes by calling pattern(i) for each new byte index i.

On grow, preserves all existing elements and truncates to new_len elements on shrink.

§Errors
§Safety
  • slice must point to a slice allocated using this allocator.
Source

unsafe fn realloc_raw_slice_patterned<T, F: Fn(usize) -> u8 + Clone>( &self, ptr: NonNull<T>, len: usize, new_len: usize, pattern: F, ) -> Result<NonNull<T>, AllocError>

Reallocates a slice to a new length given the pointer to its first element, current length, and requested length, filling any newly allocated bytes by calling pattern(i) for each new byte index i.

On grow, preserves all existing elements and truncates to new_len elements on shrink.

§Errors
§Safety
  • ptr must point to a slice allocated using this allocator.
  • len must describe exactly the number of elements in that slice.

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§