Skip to main content

Closure

Struct Closure 

Source
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>

Source

pub fn param_env(&self) -> &ParamEnv<'tcx>

Source

pub fn kind(&self) -> &ClosureKind

Source

pub fn sig(&self) -> &PolyFnSig<'tcx>

Source

pub fn upvar_tys(&self) -> &[Ty<'tcx>]

Source

pub fn inline(&self) -> &InlineAttr

Source

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.

Source

pub fn fn_trait_impls(&self, s: &impl BaseState<'tcx>) -> &FnTraitImpls<'tcx>

The virtual Fn* impls supported by this closure.

Source

pub fn destruct_impl(&self, s: &impl BaseState<'tcx>) -> &VirtualTraitImpl<'tcx>

Info required to construct a virtual Drop impl for this closure.

Trait Implementations§

Source§

impl<'tcx> Clone for Closure<'tcx>

Source§

fn clone(&self) -> Closure<'tcx>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'tcx> Debug for Closure<'tcx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more