Skip to main content

assert_allocator_basic_round_trip

Function assert_allocator_basic_round_trip 

Source
pub fn assert_allocator_basic_round_trip<A>(a: &A)
where A: Allocator,
Expand description

Verify the basic round-trip invariants of Allocator:

  • allocate returns a non-null, appropriately aligned pointer to at least layout.size() writable bytes.
  • Two successive allocations from the same instance never overlap.
  • allocate_zeroed yields a block whose layout.size() bytes are all zero.
  • deallocate accepts every issued pointer without panicking.

Uses a 64-byte, 8-aligned layout. Allocators that legitimately reject this size should not be tested with this helper — use assert_allocator_respects_alignment for a finer-grained alignment probe.

Panics on the first violated invariant.