Skip to content

Commit b01c802

Browse files
committed
Trait object syntax + trailing plus
1 parent ec079d3 commit b01c802

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/types.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ Because captures are often by reference, the following general rules arise:
498498

499499
## Trait objects
500500

501+
> **<sup>Syntax</sup>**
502+
> _TraitObjectType_ :
503+
> &nbsp;&nbsp; [_Path_] ( `+` [_Path_] )<sup>\*</sup> `+`<sup>?</sup>
504+
501505
A *trait object* is an opaque value of another type that implements a set of
502506
traits. The set of traits is made up of an [object safe] *base trait* plus any
503507
number of [auto traits].
@@ -506,10 +510,10 @@ Trait objects implement the base trait, its auto traits, and any super traits
506510
of the base trait.
507511

508512
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`.
513+
of auto traits followed optionally by a lifetime bound all separated by and
514+
optionally terminated by `+`. For example, given a trait `Trait`, the following
515+
are all trait objects: `Trait`, `Trait + Send`, `Trait + Send + Sync`,
516+
`Trait + 'static`, `Trait + Send + 'static`, `Trait +`.
513517

514518
Two trait object types alias each other if the base traits alias each other and
515519
if the sets of auto traits are the same and the lifetime bounds are the same.
@@ -701,3 +705,4 @@ impl Printable for String {
701705
[object safe]: items/traits.html#object-safety
702706
[issue 47010]: https://github.com/rust-lang/rust/issues/47010
703707
[issue 33140]: https://github.com/rust-lang/rust/issues/33140
708+
[_PATH_]: paths.html

0 commit comments

Comments
 (0)