Skip to content

Commit 50e2f55

Browse files
author
Nick Hamann
committed
Partially audit the trait objects section.
Mention object-safety for traits, link to RFC 255.
1 parent daa542b commit 50e2f55

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/doc/reference.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,11 +3387,12 @@ more of the closure traits:
33873387
### Trait objects
33883388

33893389
Every trait item (see [traits](#traits)) defines a type with the same name as
3390-
the trait. This type is called the _trait object_ of the trait. Trait objects
3391-
permit "late binding" of methods, dispatched using _virtual method tables_
3392-
("vtables"). Whereas most calls to trait methods are "early bound" (statically
3393-
resolved) to specific implementations at compile time, a call to a method on an
3394-
trait objects is only resolved to a vtable entry at compile time. The actual
3390+
the trait. Traits that are object-safe (see [RFC 255][rfc255]) can be
3391+
instantiated as _trait objects_, which permit "late binding" of methods,
3392+
dispatched using _virtual method tables_ ("vtables"). Whereas most calls to
3393+
trait methods are "early bound" (statically resolved) to specific
3394+
implementations at compile time, a call to a method on an trait objects is
3395+
only resolved to a vtable entry at compile time. The actual
33953396
implementation for each vtable entry can vary on an object-by-object basis.
33963397

33973398
Given a pointer-typed expression `E` of type `&T` or `Box<T>`, where `T`
@@ -3679,3 +3680,4 @@ that have since been removed):
36793680

36803681
[ffi]: book/ffi.html
36813682
[plugin]: book/compiler-plugins.html
3683+
[rfc255]: https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md

0 commit comments

Comments
 (0)