pub struct Closure<'tcx> {
def_id: DefId,
fn_trait_args: [Ty<'tcx>; 2],
kind: ClosureKind,
param_env: ParamEnv<'tcx>,
sig: PolyFnSig<'tcx>,
upvar_tys: Vec<Ty<'tcx>>,
inline: InlineAttr,
fn_trait_impls: OnceCell<FnTraitImpls<'tcx>>,
destruct_impl: OnceCell<Box<VirtualTraitImpl<'tcx>>>,
}Expand description
A closure, coroutine, or coroutine-closure.
Fields§
§def_id: DefId§fn_trait_args: [Ty<'tcx>; 2][closure_ty, tupled_args_ty]: the args of the Fn* traits for this closure.
The signature’s bound regions are liberated in these types, and the extra_regions may be
mentioned as well.
kind: ClosureKind§param_env: ParamEnv<'tcx>The closure inherits its ordinary generics from its parent. It does have type parameters,
used by rustc for inference purposes. These are hidden from the ParamEnv. Any erased
lifetimes found in these inferred generics are replaced with placeholder regions, stored in
extra_early_regions.
sig: PolyFnSig<'tcx>§upvar_tys: Vec<Ty<'tcx>>The captured variables, which together form the closure’s state.
inline: InlineAttr§fn_trait_impls: OnceCell<FnTraitImpls<'tcx>>Computed on demand, see Closure::fn_trait_impls.
destruct_impl: OnceCell<Box<VirtualTraitImpl<'tcx>>>Implementations§
Source§impl<'tcx> Closure<'tcx>
impl<'tcx> Closure<'tcx>
pub fn param_env(&self) -> &ParamEnv<'tcx>
pub fn kind(&self) -> &ClosureKind
pub fn sig(&self) -> &PolyFnSig<'tcx>
pub fn upvar_tys(&self) -> &[Ty<'tcx>]
pub fn inline(&self) -> &InlineAttr
Sourcefn virtual_impl(
&self,
s: &impl BaseState<'tcx>,
trait_lang_item: LangItem,
trait_args: &[Ty<'tcx>],
) -> Box<VirtualTraitImpl<'tcx>>
fn virtual_impl( &self, s: &impl BaseState<'tcx>, trait_lang_item: LangItem, trait_args: &[Ty<'tcx>], ) -> Box<VirtualTraitImpl<'tcx>>
The virtual impl of this closure for the given trait.
Sourcepub fn fn_trait_impls(&self, s: &impl BaseState<'tcx>) -> &FnTraitImpls<'tcx>
pub fn fn_trait_impls(&self, s: &impl BaseState<'tcx>) -> &FnTraitImpls<'tcx>
The virtual Fn* impls supported by this closure.
Sourcepub fn destruct_impl(&self, s: &impl BaseState<'tcx>) -> &VirtualTraitImpl<'tcx>
pub fn destruct_impl(&self, s: &impl BaseState<'tcx>) -> &VirtualTraitImpl<'tcx>
Info required to construct a virtual Drop impl for this closure.
Trait Implementations§
Auto Trait Implementations§
impl<'tcx> !DynSync for Closure<'tcx>
impl<'tcx> !Freeze for Closure<'tcx>
impl<'tcx> !RefUnwindSafe for Closure<'tcx>
impl<'tcx> !Sync for Closure<'tcx>
impl<'tcx> !UnwindSafe for Closure<'tcx>
impl<'tcx> DynSend for Closure<'tcx>
impl<'tcx> Send for Closure<'tcx>
impl<'tcx> Unpin for Closure<'tcx>
impl<'tcx> UnsafeUnpin for Closure<'tcx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more