@@ -2997,11 +2997,13 @@ mod tests {
2997
2997
2998
2998
let ( info, ptr) = iter. next ( ) . unwrap ( ) ;
2999
2999
assert_eq ! ( info. name( ) , std:: any:: type_name:: <TestResource >( ) ) ;
3000
+ // SAFETY: We know that the resource is of type `TestResource`
3000
3001
assert_eq ! ( unsafe { ptr. deref:: <TestResource >( ) . 0 } , 42 ) ;
3001
3002
3002
3003
let ( info, ptr) = iter. next ( ) . unwrap ( ) ;
3003
3004
assert_eq ! ( info. name( ) , std:: any:: type_name:: <TestResource2 >( ) ) ;
3004
3005
assert_eq ! (
3006
+ // SAFETY: We know that the resource is of type `TestResource2`
3005
3007
unsafe { & ptr. deref:: <TestResource2 >( ) . 0 } ,
3006
3008
& "Hello, world!" . to_string( )
3007
3009
) ;
@@ -3020,13 +3022,17 @@ mod tests {
3020
3022
3021
3023
let ( info, mut mut_untyped) = iter. next ( ) . unwrap ( ) ;
3022
3024
assert_eq ! ( info. name( ) , std:: any:: type_name:: <TestResource >( ) ) ;
3023
- unsafe { mut_untyped. as_mut ( ) . deref_mut :: < TestResource > ( ) . 0 = 43 } ;
3025
+ // SAFETY: We know that the resource is of type `TestResource`
3026
+ unsafe {
3027
+ mut_untyped. as_mut ( ) . deref_mut :: < TestResource > ( ) . 0 = 43 ;
3028
+ }
3024
3029
3025
3030
let ( info, mut mut_untyped) = iter. next ( ) . unwrap ( ) ;
3026
3031
assert_eq ! ( info. name( ) , std:: any:: type_name:: <TestResource2 >( ) ) ;
3032
+ // SAFETY: We know that the resource is of type `TestResource2`
3027
3033
unsafe {
3028
- mut_untyped. as_mut ( ) . deref_mut :: < TestResource2 > ( ) . 0 = "Hello, world?" . to_string ( )
3029
- } ;
3034
+ mut_untyped. as_mut ( ) . deref_mut :: < TestResource2 > ( ) . 0 = "Hello, world?" . to_string ( ) ;
3035
+ }
3030
3036
3031
3037
assert ! ( iter. next( ) . is_none( ) ) ;
3032
3038
0 commit comments