@@ -498,18 +498,25 @@ Because captures are often by reference, the following general rules arise:
498498
499499## Trait objects
500500
501+ > ** <sup >Syntax</sup >**
502+ > _ TraitObjectType_ :
503+ >   ;  ; [ _ LifetimeOrPath_ ] ( ` + ` [ _ LifetimeOrPath_ ] )<sup >\* </sup > ` + ` <sup >?</sup >
504+ >
505+ > _ LifetimeOrPath_ :
506+ >   ;  ; [ _ Path_ ] | [ _ LIFETIME_OR_LABEL_ ]
507+
501508A * trait object* is an opaque value of another type that implements a set of
502509traits. The set of traits is made up of an [ object safe] * base trait* plus any
503510number of [ auto traits] .
504511
505512Trait objects implement the base trait, its auto traits, and any super traits
506513of the base trait.
507514
508- Trait objects are written as the path to the base trait followed by the list
509- of auto traits followed optionally by a lifetime bound all separated by ` + ` . For
510- example, given a trait ` Trait ` , the following are all trait objects: ` Trait ` ,
511- ` Trait + Send ` , ` Trait + Send + Sync ` , ` Trait + 'static ` ,
512- ` Trait + Send + 'static ` .
515+ Trait objects are written the same as trait bounds with the exception that all
516+ traits except the first trait must be auto traits and there may not be more than
517+ one lifetime. For example, given a trait ` Trait ` , the following
518+ are all trait objects: ` Trait ` , ` Trait + Send ` , ` Trait + Send + Sync ` ,
519+ ` Trait + 'static ` , ` Trait + Send + 'static` , ` Trait + ` , ` 'static + Trait ` .
513520
514521Two trait object types alias each other if the base traits alias each other and
515522if the sets of auto traits are the same and the lifetime bounds are the same.
@@ -701,3 +708,5 @@ impl Printable for String {
701708[ object safe ] : items/traits.html#object-safety
702709[ issue 47010 ] : https://github.com/rust-lang/rust/issues/47010
703710[ issue 33140 ] : https://github.com/rust-lang/rust/issues/33140
711+ [ _PATH_ ] : paths.html
712+ [ _LIFETIME_OR_LABEL_ ] : tokens.html#lifetimes-and-loop-labels
0 commit comments