#[repr(C, align(32))]pub struct StaticAllocator<const SIZE: usize> { /* private fields */ }
Expand description
Uses a statically pre-allocated section to allocate all memory.
Does not free up memory. Cannot grow beyond what was statically pre-allocated.
Never calls memory.grow
.
Largely inspired by this blog post: https://surma.dev/things/rust-to-webassembly/
Implementations§
Trait Implementations§
Source§impl<const SIZE: usize> GlobalAlloc for StaticAllocator<SIZE>
impl<const SIZE: usize> GlobalAlloc for StaticAllocator<SIZE>
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocates memory as described by the given
layout
. Read moreimpl<const SIZE: usize> Sync for StaticAllocator<SIZE>
Auto Trait Implementations§
impl<const SIZE: usize> !Freeze for StaticAllocator<SIZE>
impl<const SIZE: usize> !RefUnwindSafe for StaticAllocator<SIZE>
impl<const SIZE: usize> Send for StaticAllocator<SIZE>
impl<const SIZE: usize> Unpin for StaticAllocator<SIZE>
impl<const SIZE: usize> UnwindSafe for StaticAllocator<SIZE>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more