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 allocatingNonein the arena; orResult<&T, ErrorGuaranteed>instead of&Result<T, ErrorGuaranteed>, and avoid allocatingErr(ErrorGuaranteed)in the arena.
An arena-cached query must be declared to return a type that implements this trait, i.e.
&'tcx T, Option<&'tcx T>, or Result<&'tcx T, ErrorGuaranteed>. 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".
Implementations on Foreign Types§
Source§impl<'tcx, T> ArenaCached<'tcx> for &'tcx T
impl<'tcx, T> ArenaCached<'tcx> for &'tcx T
Source§impl<'tcx, T> ArenaCached<'tcx> for Option<&'tcx T>
impl<'tcx, T> ArenaCached<'tcx> for Option<&'tcx T>
Source§impl<'tcx, T> ArenaCached<'tcx> for Result<&'tcx T, ErrorGuaranteed>
impl<'tcx, T> ArenaCached<'tcx> for Result<&'tcx T, ErrorGuaranteed>
Source§type Allocated = T
type Allocated = T
The provide value is Result<T, ErrorGuaranteed>, but we only store T in the arena.