File tree 1 file changed +13
-0
lines changed
compiler/rustc_middle/src/ty
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -2362,6 +2362,19 @@ impl<'tcx> Ty<'tcx> {
2362
2362
/// to represent the closure kind, because it has not yet been
2363
2363
/// inferred. Once upvar inference (in `rustc_hir_analysis/src/check/upvar.rs`)
2364
2364
/// is complete, that type variable will be unified.
2365
+ ///
2366
+ /// To be noted that you can use [`ClosureArgs::kind()`] or [`CoroutineClosureArgs::kind()`]
2367
+ /// to get the same information, which you can get by calling [`GenericArgs::as_closure()`].
2368
+ ///
2369
+ /// Otherwise, this method can be used as follows:
2370
+ ///
2371
+ /// ```rust,ignore
2372
+ /// let TyKind::Closure(def_id, [closure_fn_kind_ty, ..]) = closure_ty.kind()
2373
+ /// && let Some(closure_kind) = closure_fn_kind_ty.expect_ty().to_opt_closure_kind()
2374
+ /// {
2375
+ /// // your code
2376
+ /// }
2377
+ /// ```
2365
2378
pub fn to_opt_closure_kind ( self ) -> Option < ty:: ClosureKind > {
2366
2379
match self . kind ( ) {
2367
2380
Int ( int_ty) => match int_ty {
You can’t perform that action at this time.
0 commit comments