Skip to content

Commit be26031

Browse files
committed
Rollup merge of rust-lang#24733 - nwin:patch-1, r=steveklabnik
Consistency. The book also refers to it as trait objects.
2 parents 21f278a + 99fd7f2 commit be26031

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/doc/reference.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ fn draw_twice<T: Shape>(surface: Surface, sh: T) {
15551555
}
15561556
```
15571557

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
15591559
trait. Values of this type are created by [casting](#type-cast-expressions)
15601560
pointer values (pointing to a type for which an implementation of the given
15611561
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
27442744
identifier, and a parenthesized expression-list. Method calls are resolved to
27452745
methods on specific traits, either statically dispatching to a method if the
27462746
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).
27482748

27492749
### Field expressions
27502750

@@ -3649,23 +3649,23 @@ call_closure(closure_no_args, closure_args);
36493649

36503650
```
36513651

3652-
### Object types
3652+
### Trait objects
36533653

36543654
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
36563656
permit "late binding" of methods, dispatched using _virtual method tables_
36573657
("vtables"). Whereas most calls to trait methods are "early bound" (statically
36583658
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
36603660
implementation for each vtable entry can vary on an object-by-object basis.
36613661

36623662
Given a pointer-typed expression `E` of type `&T` or `Box<T>`, where `T`
36633663
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
36653665
represented as a pair of pointers: the vtable pointer for the `T`
36663666
implementation of `R`, and the pointer value of `E`.
36673667

3668-
An example of an object type:
3668+
An example of a trait object:
36693669

36703670
```
36713671
trait Printable {
@@ -3685,7 +3685,7 @@ fn main() {
36853685
}
36863686
```
36873687

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
36893689
type signature of `print`, and the cast expression in `main`.
36903690

36913691
### Type parameters

0 commit comments

Comments
 (0)