Skip to content

Commit 3933112

Browse files
Reorder a few paragraphs
1 parent 5e4b65b commit 3933112

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

text/3437-implementable-trait-alias.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,26 @@ trait Alias = Foo {
622622
`<T as Alias>::AssocVec` means the same thing as `Vec<<T as Foo>::Assoc>`, and
623623
`<T as Alias>::ASSOC_PLUS_1` is equivalent to `const { <T as Foo>::ASSOC + 1 }`.
624624

625+
Items defined in a trait alias body shadow items of the same name in a primary
626+
trait.
627+
628+
```rust
629+
trait Foo {
630+
type Assoc;
631+
}
632+
633+
trait Bar {
634+
type Assoc;
635+
}
636+
637+
trait FooBar = Foo + Bar {
638+
type Assoc = <Self as Foo>::Assoc; // `FooBar::Assoc` will resolve to `Foo::Assoc`
639+
type BarAssoc = <Self as Bar>::Assoc;
640+
}
641+
```
642+
643+
#### Implementability
644+
625645
To be implementable, a `type` or `const` alias item must obey certain
626646
restrictions. It must either be set equal to an item of a primary trait of the
627647
alias:
@@ -687,24 +707,6 @@ trait Bar = Foo<Assoc = Result<Self::Foo, Vec<Self::Foo>>> {
687707
}
688708
```
689709

690-
Items defined in a trait alias body shadow items of the same name in a primary
691-
trait.
692-
693-
```rust
694-
trait Foo {
695-
type Assoc;
696-
}
697-
698-
trait Bar {
699-
type Assoc;
700-
}
701-
702-
trait FooBar = Foo + Bar {
703-
type Assoc = <Self as Foo>::Assoc; // `FooBar::Assoc` will resolve to `Foo::Assoc`
704-
type BarAssoc = <Self as Bar>::Assoc;
705-
}
706-
```
707-
708710
#### GATs in type alias bodies
709711

710712
Type alias bodies can also contain GATs. These are also subject to the

0 commit comments

Comments
 (0)