pub struct Guard<A = System>(/* private fields */);Expand description
The global allocator that counts large allocations, refuses those that would pass the process’s limit and, on Linux, asks for huge pages for the largest. It allocates through A: System, unless Guard::over names another global allocator, as the browser build names talc. Register it as #[global_allocator] static GUARD: Guard = Guard::new();.
Implementations§
Source§impl<A: GlobalAlloc + 'static> Guard<A>
impl<A: GlobalAlloc + 'static> Guard<A>
Sourcepub const fn over(allocator: A) -> Self
pub const fn over(allocator: A) -> Self
A guard that allocates through allocator. Guard::new gives one over System.
Trait Implementations§
Source§impl<A: GlobalAlloc + 'static> GlobalAlloc for Guard<A>
impl<A: GlobalAlloc + 'static> GlobalAlloc for Guard<A>
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 moreSource§unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
Behaves like
alloc, but also ensures that the contents
are set to zero before being returned. Read moreAuto Trait Implementations§
impl<A> Forget for Guard<A>
impl<A> Freeze for Guard<A>where
A: Freeze,
impl<A> RefUnwindSafe for Guard<A>where
A: RefUnwindSafe,
impl<A> Send for Guard<A>where
A: Send,
impl<A> Sync for Guard<A>where
A: Sync,
impl<A> Unpin for Guard<A>where
A: Unpin,
impl<A> UnsafeUnpin for Guard<A>where
A: UnsafeUnpin,
impl<A> UnwindSafe for Guard<A>where
A: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more