Skip to main content

## Erasable

# Trait Erasable

Source

    pub trait Erasable: Copy {
        type Storage: Copy;
    }

Expand description

Trait for types that can be erased into `Erased<Self>`.

Erasing and unerasing values is performed by `erase_val` and `restore_val`.

FIXME: This whole trait could potentially be replaced by `T: Copy` and the storage type `[u8; size_of::<T>()]` when support for that is more mature.

## Required Associated Types§

Source

#### type Storage: Copy

Storage type to used for erased values of this type. Should be `[u8; N]`, where N is equal to `size_of::<Self>`.

`ErasedData` wraps this storage type in `MaybeUninit` to ensure that transmutes to/from erased storage are well-defined.

## 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.

## Implementations on Foreign Types§

Source§

### impl Erasable for (&CrateInherentImpls, Result<(), ErrorGuaranteed>)

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for (QueryResult<'_>, &Probe<TyCtxt<'_>>)

Source§

#### type Storage = [u8; 48]

Source§

### impl Erasable for DefKind

Source§

#### type Storage = [u8; 3]

Source§

### impl Erasable for Constness

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Defaultness

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for MaybeOwner<'_>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for OpaqueTyOrigin<DefId>

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for OptLevel

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for SymbolManglingVersion

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for CrateDepKind

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for PanicStrategy

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Option<&OsStr>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Option<&[PreciseCapturingArgKind<Symbol, Symbol>]>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Option<(ConstValue, Ty<'_>)>

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for Option<(DefId, EntryFnType)>

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for Option<AllocatorKind>

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Option<CoroutineKind>

Source§

#### type Storage = [u8; 2]

Source§

### impl Erasable for Option<PanicStrategy>

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Option<usize>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Option<Align>

Source§

#### type Storage = [u8; 2]

Source§

### impl Erasable for Option<Svh>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Option<ConstStability>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Option<DefaultBodyStability>

Source§

#### type Storage = [u8; 20]

Source§

### impl Erasable for Option<Stability>

Source§

#### type Storage = [u8; 20]

Source§

### impl Erasable for Option<CrateNum>

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for Option<DefId>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Option<LocalDefId>

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for Option<Span>

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for Option<DeprecationEntry>

Source§

#### type Storage = [u8; 28]

Source§

### impl Erasable for Option<AsyncDestructor>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Option<Destructor>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Option<IntrinsicDef>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Option<ScalarInt>

Source§

#### type Storage = [u8; 17]

Source§

### impl Erasable for Option<Value<'_>>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Option<EarlyBinder<'_, Ty<'_>>>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Result<&ImplSource<'_, ()>, CodegenObligationError>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Result<&TokenStream, ()>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Result<&FnAbi<'_, Ty<'_>>, &FnAbiError<'_>>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Result<&List<Ty<'_>>, AlwaysRequiresDrop>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Result<(&Steal<Thir<'_>>, ExprId), ErrorGuaranteed>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Result<(&[Spanned<MonoItem<'_>>], &[Spanned<MonoItem<'_>>]), NormalizationErrorInMono>

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for Result<ConstValue, ErrorHandled>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Result<EvaluationResult, OverflowError>

Source§

#### type Storage = [u8; 2]

Source§

### impl Erasable for Result<Option<Instance<'_>>, ErrorGuaranteed>

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for Result<Option<EarlyBinder<'_, Const<'_>>>, ErrorGuaranteed>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Result<bool, &LayoutError<'_>>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Result<(), ErrorGuaranteed>

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Result<TyAndLayout<'_, Ty<'_>>, &LayoutError<'_>>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Result<ConstAlloc<'_>, ErrorHandled>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Result<CoerceUnsizedInfo, ErrorGuaranteed>

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for Result<GenericArg<'_>, NoSolution>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for bool

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for ()

Source§

#### type Storage = [u8; 0]

Source§

### impl Erasable for usize

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Svh

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for HirId

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Limits

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for DefId

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ExpnId

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Span

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Symbol

Source§

#### type Storage = [u8; 4]

Source§

### impl<T0, T1> Erasable for (&T0, &T1)

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for &[T]

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for Option<&T>

Source§

#### type Storage = [u8; 8]

Source§

### impl<T> Erasable for Result<&T, ErrorGuaranteed>

Source§

#### type Storage = [u8; 8]

Source§

### impl<T> Erasable for Result<&T, NoSolution>

Source§

#### type Storage = [u8; 8]

Source§

### impl<T> Erasable for &T

Source§

#### type Storage = [u8; 8]

## Implementors§

Source§

### impl Erasable for ObjectLifetimeDefault

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ConstValue

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for AnonConstKind

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Asyncness

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Visibility<DefId>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for InhabitedPredicate<'_>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for SanitizerFnAttrs

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for AllocId

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ConstQualifs

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for MonoItemPartitions<'_>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for MethodAutoderefStepsResult<'_>

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for AdtDef<'_>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for AssocItem

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for ClosureTypeInfo<'_>

Source§

#### type Storage = [u8; 56]

Source§

### impl Erasable for Const<'_>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ConstConditions<'_>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for GenericPredicates<'_>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for ImplTraitHeader<'_>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for ParamEnv<'_>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for SymbolName<'_>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Ty<'_>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for TypingEnv<'_>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for EvalStaticInitializerRawResult<'_>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for EvalToValTreeResult<'_>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Binder<'_, CoroutineWitnessTypes<TyCtxt<'_>>>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Binder<'_, FnSig<'_>>

Source§

#### type Storage = [u8; 24]

Source§

### impl<H, T> Erasable for &RawList<H, T>

Source§

#### type Storage = [u8; 8]

Source§

### impl<T: Erasable> Erasable for EarlyBinder<'_, T>

Source§

#### type Storage = <T as Erasable>::Storage