Skip to content

Commit 2f16bdf

Browse files
committed
More restrictions on trait objects
1 parent 494d490 commit 2f16bdf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/types.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ Because captures are often by reference, the following general rules arise:
500500

501501
> **<sup>Syntax</sup>**
502502
> _TraitObjectType_ :
503-
> &nbsp;&nbsp; [_LifetimeOrPath_] ( `+` [_LifetimeOrPath_] )<sup>\*</sup> `+`<sup>?</sup>
503+
> &nbsp;&nbsp; _LifetimeOrPath_ ( `+` _LifetimeOrPath_ )<sup>\*</sup> `+`<sup>?</sup>
504504
>
505505
> _LifetimeOrPath_ :
506506
> &nbsp;&nbsp; [_Path_] | [_LIFETIME_OR_LABEL_]
@@ -512,11 +512,12 @@ number of [auto traits].
512512
Trait objects implement the base trait, its auto traits, and any super traits
513513
of the base trait.
514514

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`.
515+
Trait objects are written the same as trait bounds, but with the following
516+
restrictions. All traits except the first trait must be auto traits, there may
517+
not be more than one lifetime, and opt-out bounds (e.g. `?sized`) are not
518+
allowed. For example, given a trait `Trait`, the following are all trait
519+
objects: `Trait`, `Trait + Send`, `Trait + Send + Sync`, `Trait + 'static`,
520+
`Trait + Send + 'static`, `Trait +`, `'static + Trait`.
520521

521522
Two trait object types alias each other if the base traits alias each other and
522523
if the sets of auto traits are the same and the lifetime bounds are the same.

0 commit comments

Comments
 (0)