@@ -679,10 +679,7 @@ macro_rules! glib_object_wrapper {
679
679
#[ doc( hidden) ]
680
680
impl AsRef <$super_name> for $name {
681
681
fn as_ref( & self ) -> & $super_name {
682
- debug_assert!( $crate:: object:: ObjectExt :: is:: <$super_name>( self ) ) ;
683
- unsafe {
684
- :: std:: mem:: transmute( self )
685
- }
682
+ $crate:: object:: Cast :: upcast_ref( self )
686
683
}
687
684
}
688
685
} ;
@@ -700,9 +697,13 @@ macro_rules! glib_object_wrapper {
700
697
type Target = <$crate:: object:: Object as $crate:: object:: ObjectType >:: RustClassType ;
701
698
702
699
fn deref( & self ) -> & Self :: Target {
703
- unsafe {
704
- :: std:: mem:: transmute( self )
705
- }
700
+ $crate:: object:: IsClassFor :: upcast_ref( self )
701
+ }
702
+ }
703
+
704
+ impl :: std:: ops:: DerefMut for $rust_class_name {
705
+ fn deref_mut( & mut self ) -> & mut Self :: Target {
706
+ $crate:: object:: IsClassFor :: upcast_ref_mut( self )
706
707
}
707
708
}
708
709
} ;
@@ -715,9 +716,13 @@ macro_rules! glib_object_wrapper {
715
716
type Target = <$super_name as $crate:: object:: ObjectType >:: RustClassType ;
716
717
717
718
fn deref( & self ) -> & Self :: Target {
718
- unsafe {
719
- :: std:: mem:: transmute( self )
720
- }
719
+ $crate:: object:: IsClassFor :: upcast_ref( self )
720
+ }
721
+ }
722
+
723
+ impl :: std:: ops:: DerefMut for $rust_class_name {
724
+ fn deref_mut( & mut self ) -> & mut Self :: Target {
725
+ $crate:: object:: IsClassFor :: upcast_ref_mut( self )
721
726
}
722
727
}
723
728
} ;
@@ -730,9 +735,13 @@ macro_rules! glib_object_wrapper {
730
735
type Target = <$super_name as $crate:: object:: ObjectType >:: RustClassType ;
731
736
732
737
fn deref( & self ) -> & Self :: Target {
733
- unsafe {
734
- :: std:: mem:: transmute( self )
735
- }
738
+ $crate:: object:: IsClassFor :: upcast_ref( self )
739
+ }
740
+ }
741
+
742
+ impl :: std:: ops:: DerefMut for $rust_class_name {
743
+ fn deref_mut( & mut self ) -> & mut Self :: Target {
744
+ $crate:: object:: IsClassFor :: upcast_ref_mut( self )
736
745
}
737
746
}
738
747
@@ -770,10 +779,7 @@ macro_rules! glib_object_wrapper {
770
779
#[ doc( hidden) ]
771
780
impl AsRef <$crate:: object:: Object > for $name {
772
781
fn as_ref( & self ) -> & $crate:: object:: Object {
773
- debug_assert!( $crate:: object:: ObjectExt :: is:: <$crate:: object:: Object >( self ) ) ;
774
- unsafe {
775
- :: std:: mem:: transmute( self )
776
- }
782
+ $crate:: object:: Cast :: upcast_ref( self )
777
783
}
778
784
}
779
785
@@ -789,10 +795,7 @@ macro_rules! glib_object_wrapper {
789
795
#[ doc( hidden) ]
790
796
impl AsRef <$crate:: object:: Object > for $name {
791
797
fn as_ref( & self ) -> & $crate:: object:: Object {
792
- debug_assert!( $crate:: object:: ObjectExt :: is:: <$crate:: object:: Object >( self ) ) ;
793
- unsafe {
794
- :: std:: mem:: transmute( self )
795
- }
798
+ $crate:: object:: Cast :: upcast_ref( self )
796
799
}
797
800
}
798
801
0 commit comments