Struct fixed_typed_arena::ManuallyDropArena[][src]

pub struct ManuallyDropArena<T, ChunkSize: Unsigned = U16>(_);

Like Arena, but returns references of any lifetime, including 'static.

This lets the arena be used without being borrowed, but it comes with the tradeoff that the arena leaks memory unless the unsafe drop method is called.

Implementations

impl<T, ChunkSize: Unsigned> ManuallyDropArena<T, ChunkSize>[src]

pub fn new() -> Self[src]

Creates a new ManuallyDropArena.

#[must_use]pub fn alloc<'a>(&mut self, value: T) -> &'a mut T[src]

Allocates a new item in the arena and initializes it with value. Returns a reference to the allocated item. The reference can have any lifetime, including 'static, as long as T outlives that lifetime.

pub unsafe fn drop(&mut self)[src]

Drops the contents of the arena. The arena will leak memory when dropped unless this method is called.

Safety

You must ensure that no references to items (or parts of items) in the arena exist when calling this method, except possibly for references within the items themselves.

However, if there are references to other items (or parts of items) within the items themselves, at least one of the following must be true:

  • T does not have a custom Drop impl.
  • T’s Drop impl does not directly or indirectly access any data via the references to other items or parts of items. (This is essentially the requirement imposed by #[may_dangle].)

Trait Implementations

impl<T, ChunkSize: Unsigned> Default for ManuallyDropArena<T, ChunkSize>[src]

Auto Trait Implementations

impl<T, ChunkSize = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>> !Send for ManuallyDropArena<T, ChunkSize>[src]

impl<T, ChunkSize = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>> !Sync for ManuallyDropArena<T, ChunkSize>[src]

impl<T, ChunkSize> Unpin for ManuallyDropArena<T, ChunkSize> where
    T: Unpin
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.