pub trait ArenaCached<'tcx>: Sized {
type Provided;
type Allocated: 'tcx;
// Required method
fn alloc_in_arena(
tcx: TyCtxt<'tcx>,
typed_arena: &'tcx TypedArena<Self::Allocated>,
value: Self::Provided,
) -> Self;
}Expand description
Helper trait that allows arena_cache queries to return Option<&T>
instead of &Option<T>, and avoid allocating None in the arena.
An arena-cached query must be declared to return a type that implements
this trait, i.e. either &'tcx T or Option<&'tcx T>. This trait then
determines the types returned by the provider and stored in the arena,
and provides a function to bridge between the three types.
Required Associated Types§
Required Methods§
Sourcefn alloc_in_arena(
tcx: TyCtxt<'tcx>,
typed_arena: &'tcx TypedArena<Self::Allocated>,
value: Self::Provided,
) -> Self
fn alloc_in_arena( tcx: TyCtxt<'tcx>, typed_arena: &'tcx TypedArena<Self::Allocated>, value: Self::Provided, ) -> Self
Takes a provided value, and allocates it in an appropriate arena,
unless the particular value doesn’t need allocation (e.g. None).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.