@@ -405,10 +405,8 @@ x = bo(5,7);
405
405
406
406
In Rust, trait names also refer to [ dynamically sized types] called _ trait
407
407
objects_ . Like all <abbr title =" dynamically sized types " >DSTs</abbr >, trait
408
- objects are used behind some kind of pointer: ` &SomeTrait ` or ` Box<SomeTrait> ` .
409
- Each instance of a pointer to a trait object includes:
410
-
411
- [ dynamically sized types ] : dynamically-sized-types.html
408
+ objects are used behind some type of pointer; for example ` &SomeTrait ` or
409
+ ` Box<SomeTrait> ` . Each instance of a pointer to a trait object includes:
412
410
413
411
- a pointer to an instance of a type ` T ` that implements ` SomeTrait `
414
412
- a _ virtual method table_ , often just called a _ vtable_ , which contains, for
@@ -421,9 +419,8 @@ function pointer is loaded from the trait object vtable and invoked indirectly.
421
419
The actual implementation for each vtable entry can vary on an object-by-object
422
420
basis.
423
421
424
- Note that trait object types only exist for _ object-safe_ traits ([ RFC 255] ):
425
-
426
- [ RFC 255 ] : https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md
422
+ Note that trait object types only exist for
423
+ <span id =" object-safety " >* object-safe* </span > traits ([ RFC 255] ):
427
424
428
425
* It must not require ` Self: Sized `
429
426
* All associated functions must either have a ` where Self: Sized ` bound or
@@ -467,9 +464,6 @@ need to be expressed as part of the trait object. The assumed lifetime of
467
464
references held by a trait object is called its _ default object lifetime bound_ .
468
465
These were defined in [ RFC 599] and amended in [ RFC 1156] .
469
466
470
- [ RFC 599 ] : https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
471
- [ RFC 1156 ] : https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md
472
-
473
467
For traits that themselves have no lifetime parameters:
474
468
* If there is a unique bound from the containing type then that is the default
475
469
* If there is more than one bound from the containing type then an explicit bound must
@@ -580,3 +574,8 @@ impl Printable for String {
580
574
```
581
575
582
576
The notation ` &self ` is a shorthand for ` self: &Self ` .
577
+
578
+ [ dynamically sized types ] : dynamically-sized-types.html
579
+ [ RFC 599 ] : https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
580
+ [ RFC 1156 ] : https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md
581
+ [ RFC 255 ] : https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md
0 commit comments