@@ -98,26 +98,28 @@ Associated functions whose first parameter is named `self` are called *methods*
9898and may be invoked using the [ method call operator] , for example, ` x.foo() ` , as
9999well as the usual function call notation.
100100
101- If the type of the ` self ` parameter is specified, it is limited to one of the
102- following types:
101+ If the type of the ` self ` parameter is specified, it is limited to semantic
102+ types generated by the following grammar (where ` 'lt ` denotes some arbitrary
103+ lifetime):
103104
104- - ` Self `
105- - ` &Self `
106- - ` &mut Self `
107- - [ ` Box<Self> ` ]
108- - [ ` Rc<Self> ` ]
109- - [ ` Arc<Self> ` ]
110- - [ ` Pin<P> ` ] where ` P ` is one of the above types except ` Self ` .
105+ ``` text
106+ P = &'lt S | &'lt mut S | Box<S> | Rc<S> | Arc<S> | Pin<P>
107+ S = Self | P
108+ ```
111109
112- The ` Self ` term can be replaced with the type being implemented, including
113- type aliases for the type, or any nested combination of the above types.
110+ The ` Self ` terminal in this grammar is the semantic ` Self ` type and can be
111+ replaced with the type being implemented, including type aliases or associated
112+ type projections for the type.
114113
115114``` rust
116115# use std :: rc :: Rc ;
117116# use std :: sync :: Arc ;
118117# use std :: pin :: Pin ;
118+ // Examples of methods implemented on struct `Example`.
119119struct Example ;
120120type Alias = Example ;
121+ trait Trait { type Output ; }
122+ impl Trait for Example { type Output = Example ; }
121123impl Example {
122124 fn by_value (self : Self ) {}
123125 fn by_ref (self : & Self ) {}
@@ -129,6 +131,7 @@ impl Example {
129131 fn explicit_type (self : Arc <Example >) {}
130132 fn with_lifetime <'a >(self : & 'a Self ) {}
131133 fn nested <'a >(self : & mut & 'a Arc <Rc <Box <Alias >>>) {}
134+ fn via_projection (self : <Example as Trait >:: Output ) {}
132135}
133136```
134137
0 commit comments