@@ -14,15 +14,14 @@ number of [auto traits].
1414Trait objects implement the base trait, its auto traits, and any [ supertraits]
1515of the base trait.
1616
17- Trait objects are written as the optional keyword ` dyn ` followed by a set of
18- trait bounds, but with the following restrictions on the trait bounds. All
19- traits except the first trait must be auto traits, there may not be more than
20- one lifetime, and opt-out bounds (e.g. ` ?Sized ` ) are not allowed. Furthermore,
17+ Trait objects are written as the keyword ` dyn ` followed by a set of trait
18+ bounds, but with the following restrictions on the trait bounds. All traits
19+ except the first trait must be auto traits, there may not be more than one
20+ lifetime, and opt-out bounds (e.g. ` ?Sized ` ) are not allowed. Furthermore,
2121paths to traits may be parenthesized.
2222
2323For example, given a trait ` Trait ` , the following are all trait objects:
2424
25- * ` Trait `
2625* ` dyn Trait `
2726* ` dyn Trait + Send `
2827* ` dyn Trait + Send + Sync `
@@ -32,6 +31,12 @@ For example, given a trait `Trait`, the following are all trait objects:
3231* ` dyn 'static + Trait ` .
3332* ` dyn (Trait) `
3433
34+ > ** Edition Differences** : Before the 2021 edition, the ` dyn ` keyword may be
35+ > omitted.
36+ >
37+ > Note: For clarity, it is recommended to always use the ` dyn ` keyword on your
38+ > trait objects unless your codebase supports compiling with Rust 1.26 or lower.
39+
3540> ** Edition Differences** : In the 2015 edition, if the first bound of the
3641> trait object is a path that starts with ` :: ` , then the ` dyn ` will be treated
3742> as a part of the path. The first path can be put in parenthesis to get
@@ -41,9 +46,6 @@ For example, given a trait `Trait`, the following are all trait objects:
4146> Beginning in the 2018 edition, ` dyn ` is a true keyword and is not allowed in
4247> paths, so the parentheses are not necessary.
4348
44- > Note: For clarity, it is recommended to always use the ` dyn ` keyword on your
45- > trait objects unless your codebase supports compiling with Rust 1.26 or lower.
46-
4749Two trait object types alias each other if the base traits alias each other and
4850if the sets of auto traits are the same and the lifetime bounds are the same.
4951For example, ` dyn Trait + Send + UnwindSafe ` is the same as
0 commit comments