Skip to content

Commit ecfcb4c

Browse files
authored
Rollup merge of #65370 - Cerberuser:patch-1, r=jonas-schievink
Add `dyn` to `Any` documentation I noticed that in documentation to `Any` trait the old trait object syntax is used, which could be confusing for newcomers, since we generally recommend using `dyn Trait` instead of just `Trait`. This PR changes the documentation comment, so that it uses `&dyn Any`, `&mut dyn Any` and `Box<dyn Any>`, correspondingly.
2 parents 77f6853 + 0510bbf commit ecfcb4c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libcore/any.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
//! of any `'static` type through runtime reflection.
33
//!
44
//! `Any` itself can be used to get a `TypeId`, and has more features when used
5-
//! as a trait object. As `&Any` (a borrowed trait object), it has the `is` and
6-
//! `downcast_ref` methods, to test if the contained value is of a given type,
7-
//! and to get a reference to the inner value as a type. As `&mut Any`, there
5+
//! as a trait object. As `&dyn Any` (a borrowed trait object), it has the `is`
6+
//! and `downcast_ref` methods, to test if the contained value is of a given type,
7+
//! and to get a reference to the inner value as a type. As `&mut dyn Any`, there
88
//! is also the `downcast_mut` method, for getting a mutable reference to the
9-
//! inner value. `Box<Any>` adds the `downcast` method, which attempts to
9+
//! inner value. `Box<dyn Any>` adds the `downcast` method, which attempts to
1010
//! convert to a `Box<T>`. See the [`Box`] documentation for the full details.
1111
//!
12-
//! Note that &Any is limited to testing whether a value is of a specified
12+
//! Note that `&dyn Any` is limited to testing whether a value is of a specified
1313
//! concrete type, and cannot be used to test whether a type implements a trait.
1414
//!
1515
//! [`Box`]: ../../std/boxed/struct.Box.html

0 commit comments

Comments
 (0)