@@ -1555,7 +1555,7 @@ fn draw_twice<T: Shape>(surface: Surface, sh: T) {
1555
1555
}
1556
1556
```
1557
1557
1558
- Traits also define an [ object type ] ( #object-types ) with the same name as the
1558
+ Traits also define an [ trait object ] ( #trait-objects ) with the same name as the
1559
1559
trait. Values of this type are created by [ casting] ( #type-cast-expressions )
1560
1560
pointer values (pointing to a type for which an implementation of the given
1561
1561
trait is in scope) to pointers to the trait name, used as a type.
@@ -2744,7 +2744,7 @@ A _method call_ consists of an expression followed by a single dot, an
2744
2744
identifier, and a parenthesized expression-list. Method calls are resolved to
2745
2745
methods on specific traits, either statically dispatching to a method if the
2746
2746
exact ` self ` -type of the left-hand-side is known, or dynamically dispatching if
2747
- the left-hand-side expression is an indirect [ object type ] ( #object-types ) .
2747
+ the left-hand-side expression is an indirect [ trait object ] ( #trait-objects ) .
2748
2748
2749
2749
### Field expressions
2750
2750
@@ -3649,23 +3649,23 @@ call_closure(closure_no_args, closure_args);
3649
3649
3650
3650
```
3651
3651
3652
- ### Object types
3652
+ ### Trait objects
3653
3653
3654
3654
Every trait item (see [ traits] ( #traits ) ) defines a type with the same name as
3655
- the trait. This type is called the _ object type _ of the trait. Object types
3655
+ the trait. This type is called the _ trait object _ of the trait. Trait objects
3656
3656
permit "late binding" of methods, dispatched using _ virtual method tables_
3657
3657
("vtables"). Whereas most calls to trait methods are "early bound" (statically
3658
3658
resolved) to specific implementations at compile time, a call to a method on an
3659
- object type is only resolved to a vtable entry at compile time. The actual
3659
+ trait objects is only resolved to a vtable entry at compile time. The actual
3660
3660
implementation for each vtable entry can vary on an object-by-object basis.
3661
3661
3662
3662
Given a pointer-typed expression ` E ` of type ` &T ` or ` Box<T> ` , where ` T `
3663
3663
implements trait ` R ` , casting ` E ` to the corresponding pointer type ` &R ` or
3664
- ` Box<R> ` results in a value of the _ object type _ ` R ` . This result is
3664
+ ` Box<R> ` results in a value of the _ trait object _ ` R ` . This result is
3665
3665
represented as a pair of pointers: the vtable pointer for the ` T `
3666
3666
implementation of ` R ` , and the pointer value of ` E ` .
3667
3667
3668
- An example of an object type :
3668
+ An example of a trait object :
3669
3669
3670
3670
```
3671
3671
trait Printable {
@@ -3685,7 +3685,7 @@ fn main() {
3685
3685
}
3686
3686
```
3687
3687
3688
- In this example, the trait ` Printable ` occurs as an object type in both the
3688
+ In this example, the trait ` Printable ` occurs as a trait object in both the
3689
3689
type signature of ` print ` , and the cast expression in ` main ` .
3690
3690
3691
3691
### Type parameters
0 commit comments