pub struct Bump<A: BackingAllocator> { /* private fields */ }
Expand description

A bump allocator.

For a general discussion of bump allocation, see the module-level documentation.

Implementations

Constructs a new Bump from a raw pointer.

Safety

The caller must uphold the following invariants:

  • region must be a pointer to a region that fits layout, and it must be valid for reads and writes for the entire size indicated by layout.
  • No references to the memory at region may exist when this function is called.
  • As long as the returned Bump exists, no accesses may be made to the memory at region except by way of methods on the returned Bump.
Available on crate feature alloc only.

Attempts to construct a new Bump backed by the global allocator.

The memory managed by this Bump is allocated from the global allocator according to layout.

Errors

Returns an error if sufficient memory could not be allocated from the global allocator.

Available on crate feature unstable only.

Attempts to construct a new Bump backed by backing_allocator.

The memory managed by this Bump is allocated from backing_allocator according to layout.

Errors

Returns an error if sufficient memory could not be allocated from backing_allocator.

Attempts to allocate a block of memory according to layout.

Errors

Returns Err if there is insufficient memory remaining to accommodate layout.

Deallocates a block of memory.

This operation does not increase the amount of available memory unless ptr is the last outstanding allocation from this allocator.

Safety

ptr must denote a block of memory currently allocated via this allocator.

Resets the bump allocator.

This method invalidates all outstanding allocations from this allocator. The destructors of allocated objects will not be run.

Safety

The caller must uphold the following invariants:

  • No references to memory allocated by this Bump may exist when the method is called.
  • Any pointers to memory previously allocated by this allocator may no longer be dereferenced or passed to Bump::deallocate().

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.