@@ -2103,7 +2103,7 @@ a `&T` pointer. `MutexArc` is an example of a *sharable* type with internal muta
21032103These are types that do not contain any data whose lifetime is bound to
21042104a particular stack frame. These are types that do not contain any
21052105references, or types where the only contained references
2106- have the `'static` lifetime. (For more on named lifetimes and their uses,
2106+ have the `'static` lifetime. (For more on named lifetimes and their uses,
21072107see the [references and lifetimes guide][lifetimes].)
21082108
21092109> ***Note:*** These two traits were referred to as 'kinds' in earlier
@@ -2430,23 +2430,25 @@ select the method to call at runtime.
24302430
24312431This usage of traits is similar to Java interfaces.
24322432
2433- By default, each of the three storage classes for traits enforce a
2434- particular set of built-in kinds that their contents must fulfill in
2435- order to be packaged up in a trait object of that storage class .
2433+ There are some built-in bounds, such as `Send` and `Share`, which are properties
2434+ of the components of types. By design, trait objects don't know the exact type
2435+ of their contents and so the compiler cannot reason about those properties .
24362436
2437- * The contents of owned traits (`~Trait`) must fulfill the `Send` bound.
2438- * The contents of reference traits (`&Trait`) are not constrained by any bound.
2437+ You can instruct the compiler, however, that the contents of a trait object must
2438+ acribe to a particular bound with a trailing colon (`:`). These are examples of
2439+ valid types:
24392440
2440- Consequently, the trait objects themselves automatically fulfill their
2441- respective kind bounds. However, this default behavior can be overridden by
2442- specifying a list of bounds on the trait type, for example, by writing `~Trait:`
2443- (which indicates that the contents of the owned trait need not fulfill any
2444- bounds), or by writing `~Trait:Send+Share`, which indicates that in addition
2445- to fulfilling `Send`, contents must also fulfill `Share`, and as a consequence,
2446- the trait itself fulfills `Share`.
2441+ ~~~rust
2442+ trait Foo {}
2443+ trait Bar<T> {}
24472444
2448- * `~Trait:Send` is equivalent to `~Trait`.
2449- * `&Trait:` is equivalent to `&Trait`.
2445+ fn sendable_foo(f: ~Foo:Send) { /* ... */ }
2446+ fn shareable_bar<T: Share>(b: &Bar<T>: Share) { /* ... */ }
2447+ ~~~
2448+
2449+ When no colon is specified (such as the type ` ~Foo ` ), it is inferred that the
2450+ value ascribes to no bounds. They must be added manually if any bounds are
2451+ necessary for usage.
24502452
24512453Builtin kind bounds can also be specified on closure types in the same way (for
24522454example, by writing ` fn:Send() ` ), and the default behaviours are the same as
0 commit comments