pub fn uninitialized(len: usize) -> Result<Self, AllocError> {
        // Zero-sized types:
        if mem::size_of::<T>() == 0 {
            return Ok(Self {
                ptr: NonNull::dangling(),
                len: Self::empty_len(),
            });
        }
        // The alignment requirements of `T` must be smaller than the
        // allocation granularity.
        assert!(mem::align_of::<T>() <= allocation_granularity());
        // To split the buffer in two halfs the number of elements must be a
        // multiple of two, and greater than zero to be able to mirror
        // something.
        if len == 0 {
            return Ok(Self::new());
        }
        assert!(len % 2 == 0);

        // How much memory we need:
        let alloc_size = Self::size_in_bytes(len);
        debug_assert!(alloc_size > 0);
        debug_assert!(alloc_size % 2 == 0);
        debug_assert!(alloc_size % allocation_granularity() == 0);
        debug_assert!(alloc_size >= len * mem::size_of::<T>());

        let ptr = allocate_mirrored(alloc_size)?;
        Ok(Self {
            ptr: unsafe { NonNull::new_unchecked(ptr as *mut T) },
            len: alloc_size / mem::size_of::<T>(),
            // Note: len is not a multiple of two: debug_assert!(len % 2 == 0);
        })
    }
/// Create a mirrored buffer containing `len` `T`s where the first half of
/// the buffer is mirrored into the second half.
Create a mirrored buffer containing `len` `T`s where the first half of
the buffer is mirrored into the second half.
Create a mirrored buffer containing ` len ` ` T ` s where the first half of the buffer is mirrored into the second half .
pub fn uninitialized(len: usize) -> Result<Self, AllocError> {
        // Zero-sized types:
        if mem::size_of::<T>() == 0 {
            return Ok(Self {
                ptr: NonNull::dangling(),
                len: Self::empty_len(),
            });
        }
        // The alignment requirements of `T` must be smaller than the
        // allocation granularity.
        assert!(mem::align_of::<T>() <= allocation_granularity());
        // To split the buffer in two halfs the number of elements must be a
        // multiple of two, and greater than zero to be able to mirror
        // something.
        if len == 0 {
            return Ok(Self::new());
        }
        assert!(len % 2 == 0);
        // How much memory we need:
        let alloc_size = Self::size_in_bytes(len);
        debug_assert!(alloc_size > 0);
        debug_assert!(alloc_size % 2 == 0);
        debug_assert!(alloc_size % allocation_granularity() == 0);
        debug_assert!(alloc_size >= len * mem::size_of::<T>());
        let ptr = allocate_mirrored(alloc_size)?;
        Ok(Self {
            ptr: unsafe { NonNull::new_unchecked(ptr as *mut T) },
            len: alloc_size / mem::size_of::<T>(),
            // Note: len is not a multiple of two: debug_assert!(len % 2 == 0);
        })
    }
pub fn uninitialized ( len : usize ) -> Result < Self , AllocError > { // Zero-sized types: if mem :: size_of :: < T > ( ) == 0 { return Ok ( Self { ptr : NonNull :: dangling ( ) , len : Self :: empty_len ( ) , } ) ; } // The alignment requirements of `T` must be smaller than the // allocation granularity. assert ! ( mem align_of T ( ) allocation_granularity ( ) ) ; // To split the buffer in two halfs the number of elements must be a // multiple of two, and greater than zero to be able to mirror // something. if len == 0 { return Ok ( Self :: new ( ) ) ; } assert ! ( len 2 0 ) ; // How much memory we need: let alloc_size = Self :: size_in_bytes ( len ) ; debug_assert ! ( alloc_size 0 ) ; debug_assert ! ( alloc_size 2 0 ) ; debug_assert ! ( alloc_size allocation_granularity ( ) 0 ) ; debug_assert ! ( alloc_size len mem size_of T ( ) ) ; let ptr = allocate_mirrored ( alloc_size ) ? ; Ok ( Self { ptr : unsafe { NonNull :: new_unchecked ( ptr as * mut T ) } , len : alloc_size / mem :: size_of :: < T > ( ) , // Note: len is not a multiple of two: debug_assert!(len % 2 == 0); } ) }
Create a mirrored buffer containing `len` `T`s where the first half of
the buffer is mirrored into the second half.
Create a mirrored buffer containing ` len ` ` T ` s where the first half of the buffer is mirrored into the second half .
len
usize
len
usize