This repository was archived by the owner on Oct 9, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ parameters beyond their static type.
77
77
78
78
### For preventable errors, prefer ` Result ` .
79
79
80
- Preventable errors present API designers with a choice:
80
+ For preventable errors, API designers have to make a choice:
81
81
* Permit erroneous input, return ` Result ` , and use the ` Err ` variant to inform
82
82
the client of the error.
83
83
* Treat erroneous input as a _ contract violation_ (i.e., assertion failure) and ` fail! ` .
Original file line number Diff line number Diff line change 3
3
Traits are probably Rust's most complex feature, supporting a wide range of use
4
4
cases and design tradeoffs. Patterns of trait usage are still emerging.
5
5
6
- ### Know whether a trait will be used as an object. [ OPEN ]
6
+ ### Know whether a trait will be used as an object. [ RFC ]
7
7
8
- Trait objects have some [ significant limitations] ( objects.md ) .
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.
9
11
10
- When designing a trait, decide early on whether the trait will be used as an
11
- object, in part by considering these limitations.
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.
12
18
13
- > ** [ OPEN] ** Is there more specific advice we can give here?
14
19
15
20
### Default methods [ OPEN]
16
21
You can’t perform that action at this time.
0 commit comments