pub trait ArenaCached<'tcx>: Sized {
type Provided;
type Allocated: 'tcx;
// Required method
fn alloc_in_arena(
arena_alloc: impl Fn(Self::Allocated) -> &'tcx 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§
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.