mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-03 13:37:37 +00:00
Rollup merge of #134662 - ionicmc-rs:any-safety-docs, r=Amanieu
Fix safety docs for `dyn Any + Send {+ Sync}` Fixes the `# Safety` docs for `dyn Any + Send`'s `downcast_{mut/ref}_unchecked` to show the direct instructions , where previously the would tell the user to find the docs on `dyn Any` themselves. This also adds them for `downcast_{mut/ref}_unchecked` on `dyn Any + Send + Sync`
This commit is contained in:
commit
0c93b279ea
@ -423,7 +423,8 @@ impl dyn Any + Send {
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Same as the method on the type `dyn Any`.
|
||||
/// The contained value must be of type `T`. Calling this method
|
||||
/// with the incorrect type is *undefined behavior*.
|
||||
#[unstable(feature = "downcast_unchecked", issue = "90850")]
|
||||
#[inline]
|
||||
pub unsafe fn downcast_ref_unchecked<T: Any>(&self) -> &T {
|
||||
@ -451,7 +452,8 @@ impl dyn Any + Send {
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Same as the method on the type `dyn Any`.
|
||||
/// The contained value must be of type `T`. Calling this method
|
||||
/// with the incorrect type is *undefined behavior*.
|
||||
#[unstable(feature = "downcast_unchecked", issue = "90850")]
|
||||
#[inline]
|
||||
pub unsafe fn downcast_mut_unchecked<T: Any>(&mut self) -> &mut T {
|
||||
@ -552,6 +554,10 @@ impl dyn Any + Send + Sync {
|
||||
/// assert_eq!(*x.downcast_ref_unchecked::<usize>(), 1);
|
||||
/// }
|
||||
/// ```
|
||||
/// # Safety
|
||||
///
|
||||
/// The contained value must be of type `T`. Calling this method
|
||||
/// with the incorrect type is *undefined behavior*.
|
||||
#[unstable(feature = "downcast_unchecked", issue = "90850")]
|
||||
#[inline]
|
||||
pub unsafe fn downcast_ref_unchecked<T: Any>(&self) -> &T {
|
||||
@ -576,6 +582,10 @@ impl dyn Any + Send + Sync {
|
||||
///
|
||||
/// assert_eq!(*x.downcast_ref::<usize>().unwrap(), 2);
|
||||
/// ```
|
||||
/// # Safety
|
||||
///
|
||||
/// The contained value must be of type `T`. Calling this method
|
||||
/// with the incorrect type is *undefined behavior*.
|
||||
#[unstable(feature = "downcast_unchecked", issue = "90850")]
|
||||
#[inline]
|
||||
pub unsafe fn downcast_mut_unchecked<T: Any>(&mut self) -> &mut T {
|
||||
|
Loading…
Reference in New Issue
Block a user