/// Allocates a block suitable for holding an instance of `T`.
///
/// Captures a common usage pattern for allocators.
///
/// The returned block is suitable for passing to the
/// `alloc`/`realloc` methods of this allocator.
///
/// Note to implementors: If this returns `Ok(ptr)`, then `ptr`
/// must be considered "currently allocated" and must be
/// acceptable input to methods such as `realloc` or `dealloc`,
/// *even if* `T` is a zero-sized type. In other words, if your
/// `Alloc` implementation overrides this method in a manner
/// that can return a zero-sized `ptr`, then all reallocation and
/// deallocation methods need to be similarly overridden to accept
/// such values as input.
///
/// # Errors
///
/// Returning `Err` indicates that either memory is exhausted or
/// `T` does not meet allocator's size or alignment constraints.
///
/// For zero-sized `T`, may return either of `Ok` or `Err`, but
/// will *not* yield undefined behavior.
///
/// Clients wishing to abort computation in response to an
/// allocation error are encouraged to call the allocator's `oom`
/// method, rather than directly invoking `panic!` or similar.
Allocates a block suitable for holding an instance of `T`.
Captures a common usage pattern for allocators.

The returned block is suitable for passing to the
`alloc`/`realloc` methods of this allocator.


Allocates a block suitable for holding an instance of ` T ` . Captures a common usage pattern for allocators . The returned block is suitable for passing to the ` alloc ` / ` realloc ` methods of this allocator .
fn alloc_one<T>(&mut self) -> Result<NonNull<T>, AllocErr>
        where Self: Sized
    {
        let k = Layout::new::<T>();
        if k.size() > 0 {
            unsafe { self.alloc(k).map(|p| p.cast()) }
        } else {
            Err(AllocErr)
        }
    }
fn alloc_one < T > ( & mut self ) -> Result < NonNull < T > , AllocErr > where Self : Sized { let k = Layout :: new :: < T > ( ) ; if k . size ( ) > 0 { unsafe { self . alloc ( k ) . map ( | p | p . cast ( ) ) } } else { Err ( AllocErr ) } }
Allocates a block suitable for holding an instance of `T`.
Allocates a block suitable for holding an instance of ` T ` .
&mut self
errors
Returning `Err` indicates that either memory is exhausted or
`T` does not meet allocator's size or alignment constraints.

For zero-sized `T`, may return either of `Ok` or `Err`, but
will *not* yield undefined behavior.

Clients wishing to abort computation in response to an
allocation error are encouraged to call the allocator's `oom`
method, rather than directly invoking `panic!` or similar.
Returning ` Err ` indicates that either memory is exhausted or ` T ` does not meet allocator ' s size or alignment constraints . For zero - sized ` T ` may return either of ` Ok ` or ` Err ` but will * not * yield undefined behavior . Clients wishing to abort computation in response to an allocation error are encouraged to call the allocator ' s ` oom ` method rather than directly invoking ` panic! ` or similar .