Skip to content

Commit 2b14c14

Browse files
authored
Merge pull request #4 from pnkfelix/alternatives-to-equals-where
Explicitly point out alternatives to `trait Alias = where PREDICATES;`
2 parents b5ff949 + 80dbc13 commit 2b14c14

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

text/0000-trait-alias.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,20 @@ constraints, instead of creating an alias for a set of supertraits and predicate
292292
something like `constraint Foo<T> = T: Bar, Vec<T>: Baz;`, used as `fn quux<T>(...) where Foo<T> { ... }`
293293
(i.e. direct substitution). Trait object usage is unclear.
294294

295+
## Syntax for sole `where` clause.
296+
297+
The current RFC specifies that it is possible to use only the `where` clause by leaving the list of traits empty:
298+
299+
```rust
300+
trait DebugDefault = where Self: Debug + Default;
301+
```
302+
303+
This is one of many syntaxes that are available for this construct. Alternatives include:
304+
305+
* `trait DebugDefault where Self: Debug + Default;` (which has been [considered and discarded](https://github.com/rust-lang/rfcs/pull/1733#issuecomment-257993316) because [it might look](https://github.com/rust-lang/rfcs/pull/1733#issuecomment-258495468) too much like a new trait definition)
306+
* `trait DebugDefault = _ where Self: Debug + Default;` (which was [considered and then removed](https://github.com/rust-lang/rfcs/pull/1733/commits/88d3074957276c7201147fc625f18e0ebcecc1b9#diff-ae27a1a8d977f731e67823349151bed5L116) because it is [technically unnecessary](https://github.com/rust-lang/rfcs/pull/1733#issuecomment-284252196))
307+
* `trait DebugDefault = Self where Self: Debug + Default;` (analogous to previous case but not formally discussed)
308+
295309
# Unresolved questions
296310
[unresolved]: #unresolved-questions
297311

0 commit comments

Comments
 (0)