]> git.lizzy.rs Git - rust.git/blob - src/doc/style/features/traits/README.md
Changed issue number to 36105
[rust.git] / src / doc / style / features / traits / README.md
1 % Traits
2
3 Traits are probably Rust's most complex feature, supporting a wide range of use
4 cases and design tradeoffs. Patterns of trait usage are still emerging.
5
6 ### Know whether a trait will be used as an object. [FIXME: needs RFC]
7
8 Trait objects have some [significant limitations](objects.md): methods
9 invoked through a trait object cannot use generics, and cannot use
10 `Self` except in receiver position.
11
12 When designing a trait, decide early on whether the trait will be used
13 as an [object](objects.md) or as a [bound on generics](generics.md);
14 the tradeoffs are discussed in each of the linked sections.
15
16 If a trait is meant to be used as an object, its methods should take
17 and return trait objects rather than use generics.
18
19
20 ### Default methods [FIXME]
21
22 > **[FIXME]** Guidelines for default methods.