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.
This commit is contained in:
parent
29b6e0f0a1
commit
cfda050c01
1 changed files with 5 additions and 5 deletions
|
@ -2,14 +2,14 @@
|
||||||
//! of any `'static` type through runtime reflection.
|
//! of any `'static` type through runtime reflection.
|
||||||
//!
|
//!
|
||||||
//! `Any` itself can be used to get a `TypeId`, and has more features when used
|
//! `Any` itself can be used to get a `TypeId`, and has more features when used
|
||||||
//! as a trait object. As `&Any` (a borrowed trait object), it has the `is` and
|
//! as a trait object. As `&dyn Any` (a borrowed trait object), it has the `is`
|
||||||
//! `downcast_ref` methods, to test if the contained value is of a given type,
|
//! and `downcast_ref` methods, to test if the contained value is of a given type,
|
||||||
//! and to get a reference to the inner value as a type. As `&mut Any`, there
|
//! and to get a reference to the inner value as a type. As `&mut dyn Any`, there
|
||||||
//! is also the `downcast_mut` method, for getting a mutable reference to the
|
//! is also the `downcast_mut` method, for getting a mutable reference to the
|
||||||
//! inner value. `Box<Any>` adds the `downcast` method, which attempts to
|
//! inner value. `Box<dyn Any>` adds the `downcast` method, which attempts to
|
||||||
//! convert to a `Box<T>`. See the [`Box`] documentation for the full details.
|
//! convert to a `Box<T>`. See the [`Box`] documentation for the full details.
|
||||||
//!
|
//!
|
||||||
//! Note that &Any is limited to testing whether a value is of a specified
|
//! Note that &dyn Any is limited to testing whether a value is of a specified
|
||||||
//! concrete type, and cannot be used to test whether a type implements a trait.
|
//! concrete type, and cannot be used to test whether a type implements a trait.
|
||||||
//!
|
//!
|
||||||
//! [`Box`]: ../../std/boxed/struct.Box.html
|
//! [`Box`]: ../../std/boxed/struct.Box.html
|
||||||
|
|
Loading…
Reference in a new issue