Skip to content

Commit

Permalink
Merge pull request #3 from pnkfelix/add-parametric-trait-alias-examples
Browse files Browse the repository at this point in the history
include explicit examples of parametric aliases.
  • Loading branch information
hadronized authored Apr 13, 2017
2 parents 54ca931 + bf3414d commit b5ff949
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions text/0000-trait-alias.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ the same way associated types are bound with regular traits:
fn foo<I>(int_iter: I) where I: IntoIntIterator<IntoIter = std::slice::Iter<i32>> {}
```

A trait alias can be parameterized over types and lifetimes, just like traits themselves:

```rust
trait LifetimeParametric<'a> = Iterator<Item=Cow<'a, [i32]>>;`

trait TypeParametric<T> = Iterator<Item=Cow<'static, [T]>>;
```

---

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

## Use semantics

Expand Down

0 comments on commit b5ff949

Please sign in to comment.