@@ -670,6 +670,22 @@ impl GlibPtrDefault for GStringPtr {
670
670
type GlibType = * mut c_char ;
671
671
}
672
672
673
+ impl GStringPtr {
674
+ // rustdoc-stripper-ignore-next
675
+ /// Returns the corresponding [`&GStr`].
676
+ #[ inline]
677
+ pub fn to_gstr ( & self ) -> & GStr {
678
+ unsafe { GStr :: from_ptr ( self . 0 . as_ptr ( ) ) }
679
+ }
680
+
681
+ // rustdoc-stripper-ignore-next
682
+ /// Returns the corresponding [`&str`].
683
+ #[ inline]
684
+ pub fn to_str ( & self ) -> & str {
685
+ self . to_gstr ( ) . as_str ( )
686
+ }
687
+ }
688
+
673
689
impl Clone for GStringPtr {
674
690
#[ inline]
675
691
fn clone ( & self ) -> GStringPtr {
@@ -688,37 +704,14 @@ impl Drop for GStringPtr {
688
704
689
705
impl fmt:: Debug for GStringPtr {
690
706
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
691
- f. write_str ( self . as_str ( ) )
692
- }
693
- }
694
-
695
- impl std:: ops:: Deref for GStringPtr {
696
- type Target = GStr ;
697
-
698
- #[ inline]
699
- fn deref ( & self ) -> & Self :: Target {
700
- self . as_ref ( )
701
- }
702
- }
703
-
704
- impl AsRef < GStr > for GStringPtr {
705
- #[ inline]
706
- fn as_ref ( & self ) -> & GStr {
707
- unsafe { GStr :: from_ptr ( self . 0 . as_ptr ( ) ) }
708
- }
709
- }
710
-
711
- impl AsRef < str > for GStringPtr {
712
- #[ inline]
713
- fn as_ref ( & self ) -> & str {
714
- self . as_str ( )
707
+ f. write_str ( self . to_str ( ) )
715
708
}
716
709
}
717
710
718
711
impl fmt:: Display for GStringPtr {
719
712
#[ inline]
720
713
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
721
- f. write_str ( self . as_str ( ) )
714
+ f. write_str ( self . to_str ( ) )
722
715
}
723
716
}
724
717
@@ -727,161 +720,161 @@ impl Eq for GStringPtr {}
727
720
impl PartialEq for GStringPtr {
728
721
#[ inline]
729
722
fn eq ( & self , other : & GStringPtr ) -> bool {
730
- self . as_str ( ) == other. as_str ( )
723
+ self . to_gstr ( ) == other. to_gstr ( )
731
724
}
732
725
}
733
726
734
727
impl PartialEq < GStringPtr > for String {
735
728
#[ inline]
736
729
fn eq ( & self , other : & GStringPtr ) -> bool {
737
- self . as_str ( ) == other. as_str ( )
730
+ self . as_str ( ) == other. to_str ( )
738
731
}
739
732
}
740
733
741
734
impl PartialEq < GStringPtr > for GString {
742
735
#[ inline]
743
736
fn eq ( & self , other : & GStringPtr ) -> bool {
744
- self . as_str ( ) == other. as_str ( )
737
+ self . as_str ( ) == other. to_str ( )
745
738
}
746
739
}
747
740
748
741
impl PartialEq < str > for GStringPtr {
749
742
#[ inline]
750
743
fn eq ( & self , other : & str ) -> bool {
751
- self . as_str ( ) == other
744
+ self . to_str ( ) == other
752
745
}
753
746
}
754
747
755
748
impl PartialEq < & str > for GStringPtr {
756
749
#[ inline]
757
750
fn eq ( & self , other : & & str ) -> bool {
758
- self . as_str ( ) == * other
751
+ self . to_str ( ) == * other
759
752
}
760
753
}
761
754
762
755
impl PartialEq < GStr > for GStringPtr {
763
756
#[ inline]
764
757
fn eq ( & self , other : & GStr ) -> bool {
765
- self . as_str ( ) == other
758
+ self . to_gstr ( ) == other
766
759
}
767
760
}
768
761
769
762
impl PartialEq < & GStr > for GStringPtr {
770
763
#[ inline]
771
764
fn eq ( & self , other : & & GStr ) -> bool {
772
- self . as_str ( ) == * other
765
+ self . to_gstr ( ) == * other
773
766
}
774
767
}
775
768
776
769
impl PartialEq < GStringPtr > for & str {
777
770
#[ inline]
778
771
fn eq ( & self , other : & GStringPtr ) -> bool {
779
- * self == other. as_str ( )
772
+ * self == other. to_str ( )
780
773
}
781
774
}
782
775
783
776
impl PartialEq < GStringPtr > for & GStr {
784
777
#[ inline]
785
778
fn eq ( & self , other : & GStringPtr ) -> bool {
786
- * self == other. as_str ( )
779
+ self . as_str ( ) == other. to_str ( )
787
780
}
788
781
}
789
782
790
783
impl PartialEq < String > for GStringPtr {
791
784
#[ inline]
792
785
fn eq ( & self , other : & String ) -> bool {
793
- self . as_str ( ) == other. as_str ( )
786
+ self . to_str ( ) == other. as_str ( )
794
787
}
795
788
}
796
789
797
790
impl PartialEq < GString > for GStringPtr {
798
791
#[ inline]
799
792
fn eq ( & self , other : & GString ) -> bool {
800
- self . as_str ( ) == other. as_str ( )
793
+ self . to_str ( ) == other. as_str ( )
801
794
}
802
795
}
803
796
804
797
impl PartialEq < GStringPtr > for str {
805
798
#[ inline]
806
799
fn eq ( & self , other : & GStringPtr ) -> bool {
807
- self == other. as_str ( )
800
+ self == other. to_str ( )
808
801
}
809
802
}
810
803
811
804
impl PartialEq < GStringPtr > for GStr {
812
805
#[ inline]
813
806
fn eq ( & self , other : & GStringPtr ) -> bool {
814
- self == other. as_str ( )
807
+ self == other. to_gstr ( )
815
808
}
816
809
}
817
810
818
811
impl PartialOrd < GStringPtr > for GStringPtr {
819
812
#[ inline]
820
813
fn partial_cmp ( & self , other : & GStringPtr ) -> Option < std:: cmp:: Ordering > {
821
- Some ( self . as_str ( ) . cmp ( other. as_str ( ) ) )
814
+ Some ( self . to_gstr ( ) . cmp ( other. to_gstr ( ) ) )
822
815
}
823
816
}
824
817
825
818
impl Ord for GStringPtr {
826
819
#[ inline]
827
820
fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
828
- self . as_str ( ) . cmp ( other. as_str ( ) )
821
+ self . to_gstr ( ) . cmp ( other. to_gstr ( ) )
829
822
}
830
823
}
831
824
832
825
impl PartialOrd < GStringPtr > for String {
833
826
#[ inline]
834
827
fn partial_cmp ( & self , other : & GStringPtr ) -> Option < std:: cmp:: Ordering > {
835
- Some ( self . as_str ( ) . cmp ( other. as_str ( ) ) )
828
+ Some ( self . as_str ( ) . cmp ( other. to_str ( ) ) )
836
829
}
837
830
}
838
831
839
832
impl PartialOrd < GStringPtr > for GString {
840
833
#[ inline]
841
834
fn partial_cmp ( & self , other : & GStringPtr ) -> Option < std:: cmp:: Ordering > {
842
- Some ( self . as_str ( ) . cmp ( other. as_str ( ) ) )
835
+ Some ( self . as_str ( ) . cmp ( other. to_str ( ) ) )
843
836
}
844
837
}
845
838
846
839
impl PartialOrd < String > for GStringPtr {
847
840
#[ inline]
848
841
fn partial_cmp ( & self , other : & String ) -> Option < std:: cmp:: Ordering > {
849
- Some ( self . as_str ( ) . cmp ( other. as_str ( ) ) )
842
+ Some ( self . to_str ( ) . cmp ( other. as_str ( ) ) )
850
843
}
851
844
}
852
845
853
846
impl PartialOrd < GString > for GStringPtr {
854
847
#[ inline]
855
848
fn partial_cmp ( & self , other : & GString ) -> Option < std:: cmp:: Ordering > {
856
- Some ( self . as_str ( ) . cmp ( other. as_str ( ) ) )
849
+ Some ( self . to_str ( ) . cmp ( other. as_str ( ) ) )
857
850
}
858
851
}
859
852
860
853
impl PartialOrd < GStringPtr > for str {
861
854
#[ inline]
862
855
fn partial_cmp ( & self , other : & GStringPtr ) -> Option < std:: cmp:: Ordering > {
863
- Some ( self . cmp ( other. as_str ( ) ) )
856
+ Some ( self . cmp ( other. to_str ( ) ) )
864
857
}
865
858
}
866
859
867
860
impl PartialOrd < GStringPtr > for GStr {
868
861
#[ inline]
869
862
fn partial_cmp ( & self , other : & GStringPtr ) -> Option < std:: cmp:: Ordering > {
870
- Some ( self . as_str ( ) . cmp ( other. as_str ( ) ) )
863
+ Some ( self . cmp ( other. to_gstr ( ) ) )
871
864
}
872
865
}
873
866
874
867
impl PartialOrd < str > for GStringPtr {
875
868
#[ inline]
876
869
fn partial_cmp ( & self , other : & str ) -> Option < std:: cmp:: Ordering > {
877
- Some ( self . as_str ( ) . cmp ( other) )
870
+ Some ( self . to_str ( ) . cmp ( other) )
878
871
}
879
872
}
880
873
881
874
impl PartialOrd < GStr > for GStringPtr {
882
875
#[ inline]
883
876
fn partial_cmp ( & self , other : & GStr ) -> Option < std:: cmp:: Ordering > {
884
- Some ( self . as_str ( ) . cmp ( other) )
877
+ Some ( self . to_gstr ( ) . cmp ( other) )
885
878
}
886
879
}
887
880
@@ -892,31 +885,10 @@ impl AsRef<GStringPtr> for GStringPtr {
892
885
}
893
886
}
894
887
895
- impl AsRef < std:: ffi:: OsStr > for GStringPtr {
896
- #[ inline]
897
- fn as_ref ( & self ) -> & std:: ffi:: OsStr {
898
- self . as_str ( ) . as_ref ( )
899
- }
900
- }
901
-
902
- impl AsRef < std:: path:: Path > for GStringPtr {
903
- #[ inline]
904
- fn as_ref ( & self ) -> & std:: path:: Path {
905
- self . as_str ( ) . as_ref ( )
906
- }
907
- }
908
-
909
- impl AsRef < [ u8 ] > for GStringPtr {
910
- #[ inline]
911
- fn as_ref ( & self ) -> & [ u8 ] {
912
- self . as_bytes ( )
913
- }
914
- }
915
-
916
888
impl std:: hash:: Hash for GStringPtr {
917
889
#[ inline]
918
890
fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
919
- self . as_str ( ) . hash ( state) ;
891
+ self . to_str ( ) . hash ( state) ;
920
892
}
921
893
}
922
894
0 commit comments