unsafe fn shrink_in_place(&mut self,
                              ptr: NonNull<u8>,
                              layout: Layout,
                              new_size: usize) -> Result<(), CannotReallocInPlace> {
        let _ = ptr; // this default implementation doesn't care about the actual address.
        debug_assert!(new_size <= layout.size());
        let (l, _u) = self.usable_size(&layout);
        //                      layout.size() <= _u  [guaranteed by usable_size()]
        // new_layout.size() <= layout.size()        [required by this method]
        if l <= new_size {
            Ok(())
        } else {
            Err(CannotReallocInPlace)
        }
    }
/// Attempts to shrink the allocation referenced by `ptr` to fit `new_size`.
///
/// If this returns `Ok`, then the allocator has asserted that the
/// memory block referenced by `ptr` now fits `new_size`, and
/// thus can only be used to carry data of that smaller
/// layout. (The allocator is allowed to take advantage of this,
/// carving off portions of the block for reuse elsewhere.) The
/// truncated contents of the block within the smaller layout are
/// unaltered, and ownership of block has not been transferred.
///
/// If this returns `Err`, then the memory block is considered to
/// still represent the original (larger) `layout`. None of the
/// block has been carved off for reuse elsewhere, ownership of
/// the memory block has not been transferred, and the contents of
/// the memory block are unaltered.
///
/// # Safety
///
/// This function is unsafe because undefined behavior can result
/// if the caller does not ensure all of the following:
///
/// * `ptr` must be currently allocated via this allocator,
///
/// * `layout` must *fit* the `ptr` (see above); note the
///   `new_size` argument need not fit it,
///
/// * `new_size` must not be greater than `layout.size()`
///   (and must be greater than zero),
///
/// # Errors
///
/// Returns `Err(CannotReallocInPlace)` when the allocator is
/// unable to assert that the memory block referenced by `ptr`
/// could fit `layout`.
///
/// Note that one cannot pass `CannotReallocInPlace` to the `handle_alloc_error`
/// function; clients are expected either to be able to recover from
/// `shrink_in_place` failures without aborting, or to fall back
/// on another reallocation method before resorting to an abort.
Attempts to shrink the allocation referenced by `ptr` to fit `new_size`.

If this returns `Err`, then the memory block is considered to
still represent the original (larger) `layout`. None of the
block has been carved off for reuse elsewhere, ownership of
the memory block has not been transferred, and the contents of
the memory block are unaltered.
Attempts to shrink the allocation referenced by ` ptr ` to fit ` new_size ` . If this returns ` Err ` then the memory block is considered to still represent the original ( larger ) ` layout ` . None of the block has been carved off for reuse elsewhere ownership of the memory block has not been transferred and the contents of the memory block are unaltered .
unsafe fn shrink_in_place(&mut self,
                              ptr: NonNull<u8>,
                              layout: Layout,
                              new_size: usize) -> Result<(), CannotReallocInPlace> {
        let _ = ptr; // this default implementation doesn't care about the actual address.
        debug_assert!(new_size <= layout.size());
        let (l, _u) = self.usable_size(&layout);
        //                      layout.size() <= _u  [guaranteed by usable_size()]
        // new_layout.size() <= layout.size()        [required by this method]
        if l <= new_size {
            Ok(())
        } else {
            Err(CannotReallocInPlace)
        }
    }
unsafe fn shrink_in_place ( & mut self , ptr : NonNull < u8 > , layout : Layout , new_size : usize ) -> Result < ( ) , CannotReallocInPlace > { let _ = ptr ; // this default implementation doesn't care about the actual address. debug_assert ! ( new_size layout size ( ) ) ; let ( l , _u ) = self . usable_size ( & layout ) ; //                      layout.size() <= _u  [guaranteed by usable_size()] // new_layout.size() <= layout.size()        [required by this method] if l <= new_size { Ok ( ( ) ) } else { Err ( CannotReallocInPlace ) } }
Attempts to shrink the allocation referenced by `ptr` to fit `new_size`.
Attempts to shrink the allocation referenced by ` ptr ` to fit ` new_size ` .
&mut self
ptr
NonNull<u8>
layout
Layout
new_size
usize
&mut self
ptr
NonNull<u8>
layout
Layout
new_size
usize
safety
This function is unsafe because undefined behavior can result
if the caller does not ensure all of the following.

`ptr` must be currently allocated via this allocator.

`layout` must *fit* the `ptr` ; note the
`new_size` argument need not fit it.

`new_size` must not be greater than `layout.size()`
(and must be greater than zero).
This function is unsafe because undefined behavior can result if the caller does not ensure all of the following . ` ptr ` must be currently allocated via this allocator . ` layout ` must * fit * the ` ptr ` ; note the ` new_size ` argument need not fit it . ` new_size ` must not be greater than ` layout . size () ` ( and must be greater than zero ) .
errors
Returns `Err(CannotReallocInPlace)` when the allocator is
unable to assert that the memory block referenced by `ptr`
could fit `layout`.

Note that one cannot pass `CannotReallocInPlace` to the `handle_alloc_error`
function; clients are expected either to be able to recover from
`shrink_in_place` failures without aborting, or to fall back
on another reallocation method before resorting to an abort.
Returns ` Err ( CannotReallocInPlace ) ` when the allocator is unable to assert that the memory block referenced by ` ptr ` could fit ` layout ` . Note that one cannot pass ` CannotReallocInPlace ` to the ` handle_alloc_error ` function ; clients are expected either to be able to recover from ` shrink_in_place ` failures without aborting or to fall back on another reallocation method before resorting to an abort .