Skip to content

Commit 0d14aca

Browse files
authored
Rollup merge of #86141 - amorison:link-ref-in-doc-dyn-keyword, r=kennytm
Link reference in `dyn` keyword documentation The "read more" sentence formatted "object safety" as inline code instead of providing a link to more information. This PR adds a link to the Reference about this matter, as well as the page regarding trait objects. --- We could also put these links in the very first line (instead of the link to the Book) and in the first paragraph which mentions the "object safe" requirement. Personally, I think it's good to keep the link to the Book up-front as it's more accessible than the Reference.
2 parents b1fb32d + 7728476 commit 0d14aca

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library/std/src/keyword_docs.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -2256,6 +2256,9 @@ mod await_keyword {}
22562256
/// At run-time, when a method needs to be called on the `dyn Trait`, the vtable is consulted to get
22572257
/// the function pointer and then that function pointer is called.
22582258
///
2259+
/// See the Reference for more information on [trait objects][ref-trait-obj]
2260+
/// and [object safety][ref-obj-safety].
2261+
///
22592262
/// ## Trade-offs
22602263
///
22612264
/// The above indirection is the additional runtime cost of calling a function on a `dyn Trait`.
@@ -2264,9 +2267,9 @@ mod await_keyword {}
22642267
/// However, `dyn Trait` is likely to produce smaller code than `impl Trait` / generic parameters as
22652268
/// the method won't be duplicated for each concrete type.
22662269
///
2267-
/// Read more about `object safety` and [trait object]s.
2268-
///
22692270
/// [trait object]: ../book/ch17-02-trait-objects.html
2271+
/// [ref-trait-obj]: ../reference/types/trait-object.html
2272+
/// [ref-obj-safety]: ../reference/items/traits.html#object-safety
22702273
/// [erased]: https://en.wikipedia.org/wiki/Type_erasure
22712274
mod dyn_keyword {}
22722275

0 commit comments

Comments
 (0)