/// When we create a closure, we record its kind (i.e., what trait
/// it implements) into its `ClosureSubsts` using a type
/// parameter. This is kind of a phantom type, except that the
/// most convenient thing for us to are the integral types. This
/// function converts such a special type into the closure
/// kind. To go the other way, use
/// `tcx.closure_kind_ty(closure_kind)`.
///
/// Note that during type checking, we use an inference variable
/// to represent the closure kind, because it has not yet been
/// inferred. Once upvar inference (in `src/librustc_typeck/check/upvar.rs`)
/// is complete, that type variable will be unified.
When we create a closure, we record its kind  into its `ClosureSubsts` using a type
parameter. This is kind of a phantom type, except that the
most convenient thing for us to are the integral types. This
function converts such a special type into the closure
kind.

Note that during type checking, we use an inference variable
to represent the closure kind, because it has not yet been
inferred. Once upvar inference (in `src/librustc_typeck/check/upvar.rs`)
is complete, that type variable will be unified.
When we create a closure we record its kind into its ` ClosureSubsts ` using a type parameter . This is kind of a phantom type except that the most convenient thing for us to are the integral types . This function converts such a special type into the closure kind . Note that during type checking we use an inference variable to represent the closure kind because it has not yet been inferred . Once upvar inference ( in ` src / librustc_typeck / check / upvar . rs ` ) is complete that type variable will be unified .
pub fn to_opt_closure_kind(&self) -> Option<ty::ClosureKind> {
        match self.sty {
            TyInt(int_ty) => match int_ty {
                ast::IntTy::I8 => Some(ty::ClosureKind::Fn),
                ast::IntTy::I16 => Some(ty::ClosureKind::FnMut),
                ast::IntTy::I32 => Some(ty::ClosureKind::FnOnce),
                _ => bug!("cannot convert type `{:?}` to a closure kind", self),
            },
            TyInfer(_) => None,
            TyError => Some(ty::ClosureKind::Fn),
            _ => bug!("cannot convert type `{:?}` to a closure kind", self),
        }
    }
pub fn to_opt_closure_kind ( & self ) -> Option < ty :: ClosureKind > { match self . sty { TyInt ( int_ty ) => match int_ty { ast :: IntTy :: I8 => Some ( ty :: ClosureKind :: Fn ) , ast :: IntTy :: I16 => Some ( ty :: ClosureKind :: FnMut ) , ast :: IntTy :: I32 => Some ( ty :: ClosureKind :: FnOnce ) , _ => bug ! ( " " self ) , } , TyInfer ( _ ) => None , TyError => Some ( ty :: ClosureKind :: Fn ) , _ => bug ! ( " " self ) , } }
When we create a closure, we record its kind (i.e., what trait
it implements) into its `ClosureSubsts` using a type
parameter.
When we create a closure we record its kind ( i . e . what trait it implements ) into its ` ClosureSubsts ` using a type parameter .
&self