@@ -423,7 +423,8 @@ impl dyn Any + Send {
423
423
///
424
424
/// # Safety
425
425
///
426
- /// Same as the method on the type `dyn Any`.
426
+ /// The contained value must be of type `T`. Calling this method
427
+ /// with the incorrect type is *undefined behavior*.
427
428
#[ unstable( feature = "downcast_unchecked" , issue = "90850" ) ]
428
429
#[ inline]
429
430
pub unsafe fn downcast_ref_unchecked < T : Any > ( & self ) -> & T {
@@ -451,7 +452,8 @@ impl dyn Any + Send {
451
452
///
452
453
/// # Safety
453
454
///
454
- /// Same as the method on the type `dyn Any`.
455
+ /// The contained value must be of type `T`. Calling this method
456
+ /// with the incorrect type is *undefined behavior*.
455
457
#[ unstable( feature = "downcast_unchecked" , issue = "90850" ) ]
456
458
#[ inline]
457
459
pub unsafe fn downcast_mut_unchecked < T : Any > ( & mut self ) -> & mut T {
@@ -552,6 +554,10 @@ impl dyn Any + Send + Sync {
552
554
/// assert_eq!(*x.downcast_ref_unchecked::<usize>(), 1);
553
555
/// }
554
556
/// ```
557
+ /// # Safety
558
+ ///
559
+ /// The contained value must be of type `T`. Calling this method
560
+ /// with the incorrect type is *undefined behavior*.
555
561
#[ unstable( feature = "downcast_unchecked" , issue = "90850" ) ]
556
562
#[ inline]
557
563
pub unsafe fn downcast_ref_unchecked < T : Any > ( & self ) -> & T {
@@ -576,6 +582,10 @@ impl dyn Any + Send + Sync {
576
582
///
577
583
/// assert_eq!(*x.downcast_ref::<usize>().unwrap(), 2);
578
584
/// ```
585
+ /// # Safety
586
+ ///
587
+ /// The contained value must be of type `T`. Calling this method
588
+ /// with the incorrect type is *undefined behavior*.
579
589
#[ unstable( feature = "downcast_unchecked" , issue = "90850" ) ]
580
590
#[ inline]
581
591
pub unsafe fn downcast_mut_unchecked < T : Any > ( & mut self ) -> & mut T {
0 commit comments