Rollup merge of #54781 - phansch:master, r=varkor
Add examples to `TyKind::FnDef` and `TyKind::FnPtr` docs This adds two examples to the docs of `TyKind::FnDef` and `TyKind::FnPtr`. I found these two types a bit confusing when I learned about them and I think adding these examples might help others.
This commit is contained in:
commit
9e8f522e80
@ -126,10 +126,25 @@ pub enum TyKind<'tcx> {
|
||||
Ref(Region<'tcx>, Ty<'tcx>, hir::Mutability),
|
||||
|
||||
/// The anonymous type of a function declaration/definition. Each
|
||||
/// function has a unique type.
|
||||
/// function has a unique type, which is output (for a function
|
||||
/// named `foo` returning an `i32`) as `fn() -> i32 {foo}`.
|
||||
///
|
||||
/// For example the type of `bar` here:
|
||||
///
|
||||
/// ```rust
|
||||
/// fn foo() -> i32 { 1 }
|
||||
/// let bar = foo; // bar: fn() -> i32 {foo}
|
||||
/// ```
|
||||
FnDef(DefId, &'tcx Substs<'tcx>),
|
||||
|
||||
/// A pointer to a function. Written as `fn() -> i32`.
|
||||
///
|
||||
/// For example the type of `bar` here:
|
||||
///
|
||||
/// ```rust
|
||||
/// fn foo() -> i32 { 1 }
|
||||
/// let bar: fn() -> i32 = foo;
|
||||
/// ```
|
||||
FnPtr(PolyFnSig<'tcx>),
|
||||
|
||||
/// A trait, defined with `trait`.
|
||||
|
Loading…
Reference in New Issue
Block a user