Skip to content

Commit b5ff949

Browse files
authoredApr 13, 2017
Merge pull request #3 from pnkfelix/add-parametric-trait-alias-examples
include explicit examples of parametric aliases.
2 parents 54ca931 + bf3414d commit b5ff949

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎text/0000-trait-alias.md

+10
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ the same way associated types are bound with regular traits:
133133
fn foo<I>(int_iter: I) where I: IntoIntIterator<IntoIter = std::slice::Iter<i32>> {}
134134
```
135135

136+
A trait alias can be parameterized over types and lifetimes, just like traits themselves:
137+
138+
```rust
139+
trait LifetimeParametric<'a> = Iterator<Item=Cow<'a, [i32]>>;`
140+
141+
trait TypeParametric<T> = Iterator<Item=Cow<'static, [T]>>;
142+
```
143+
136144
---
137145

138146
Specifically, the grammar being added is, in informal notation:
@@ -144,6 +152,8 @@ ATTRIBUTE* VISIBILITY? trait IDENTIFIER(<GENERIC_PARAMS>)? = GENERIC_BOUNDS (whe
144152
`GENERIC_BOUNDS` is a list of zero or more traits and lifetimes separated by `+`, the same as the
145153
current syntax for bounds on a type parameter, and `PREDICATES` is a comma-separated list of zero or
146154
more predicates, just like any other `where` clause.
155+
`GENERIC_PARAMS` is a comma-separated list of zero or more lifetime and type parameters,
156+
with optional bounds, just like other generic definitions.
147157

148158
## Use semantics
149159

0 commit comments

Comments
 (0)
Please sign in to comment.