@@ -698,6 +698,147 @@ impl OsStr {
698
698
fn bytes ( & self ) -> & [ u8 ] {
699
699
unsafe { & * ( & self . inner as * const _ as * const [ u8 ] ) }
700
700
}
701
+
702
+ /// Converts this string to its ASCII lower case equivalent in-place.
703
+ ///
704
+ /// ASCII letters 'A' to 'Z' are mapped to 'a' to 'z',
705
+ /// but non-ASCII letters are unchanged.
706
+ ///
707
+ /// To return a new lowercased value without modifying the existing one, use
708
+ /// [`to_ascii_lowercase`].
709
+ ///
710
+ /// [`to_ascii_lowercase`]: #method.to_ascii_lowercase
711
+ ///
712
+ /// # Examples
713
+ ///
714
+ /// ```
715
+ /// #![feature(osstring_ascii)]
716
+ /// use std::ffi::OsString;
717
+ ///
718
+ /// let mut s = OsString::from("GRÜßE, JÜRGEN ❤");
719
+ ///
720
+ /// s.make_ascii_lowercase();
721
+ ///
722
+ /// assert_eq!("grÜße, jÜrgen ❤", s);
723
+ /// ```
724
+ #[ unstable( feature = "osstring_ascii" , issue = "70516" ) ]
725
+ pub fn make_ascii_lowercase ( & mut self ) {
726
+ self . inner . make_ascii_lowercase ( )
727
+ }
728
+
729
+ /// Converts this string to its ASCII upper case equivalent in-place.
730
+ ///
731
+ /// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
732
+ /// but non-ASCII letters are unchanged.
733
+ ///
734
+ /// To return a new uppercased value without modifying the existing one, use
735
+ /// [`to_ascii_uppercase`].
736
+ ///
737
+ /// [`to_ascii_uppercase`]: #method.to_ascii_uppercase
738
+ ///
739
+ /// # Examples
740
+ ///
741
+ /// ```
742
+ /// #![feature(osstring_ascii)]
743
+ /// use std::ffi::OsString;
744
+ ///
745
+ /// let mut s = OsString::from("Grüße, Jürgen ❤");
746
+ ///
747
+ /// s.make_ascii_uppercase();
748
+ ///
749
+ /// assert_eq!("GRüßE, JüRGEN ❤", s);
750
+ /// ```
751
+ #[ unstable( feature = "osstring_ascii" , issue = "70516" ) ]
752
+ pub fn make_ascii_uppercase ( & mut self ) {
753
+ self . inner . make_ascii_uppercase ( )
754
+ }
755
+
756
+ /// Returns a copy of this string where each character is mapped to its
757
+ /// ASCII lower case equivalent.
758
+ ///
759
+ /// ASCII letters 'A' to 'Z' are mapped to 'a' to 'z',
760
+ /// but non-ASCII letters are unchanged.
761
+ ///
762
+ /// To lowercase the value in-place, use [`make_ascii_lowercase`].
763
+ ///
764
+ /// [`make_ascii_lowercase`]: #method.make_ascii_lowercase
765
+ ///
766
+ /// # Examples
767
+ ///
768
+ /// ```
769
+ /// #![feature(osstring_ascii)]
770
+ /// use std::ffi::OsString;
771
+ /// let s = OsString::from("Grüße, Jürgen ❤");
772
+ ///
773
+ /// assert_eq!("grüße, jürgen ❤", s.to_ascii_lowercase());
774
+ /// ```
775
+ #[ unstable( feature = "osstring_ascii" , issue = "70516" ) ]
776
+ pub fn to_ascii_lowercase ( & self ) -> OsString {
777
+ OsString :: from_inner ( self . inner . to_ascii_lowercase ( ) )
778
+ }
779
+
780
+ /// Returns a copy of this string where each character is mapped to its
781
+ /// ASCII upper case equivalent.
782
+ ///
783
+ /// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
784
+ /// but non-ASCII letters are unchanged.
785
+ ///
786
+ /// To uppercase the value in-place, use [`make_ascii_uppercase`].
787
+ ///
788
+ /// [`make_ascii_uppercase`]: #method.make_ascii_uppercase
789
+ ///
790
+ /// # Examples
791
+ ///
792
+ /// ```
793
+ /// #![feature(osstring_ascii)]
794
+ /// use std::ffi::OsString;
795
+ /// let s = OsString::from("Grüße, Jürgen ❤");
796
+ ///
797
+ /// assert_eq!("GRüßE, JüRGEN ❤", s.to_ascii_uppercase());
798
+ /// ```
799
+ #[ unstable( feature = "osstring_ascii" , issue = "70516" ) ]
800
+ pub fn to_ascii_uppercase ( & self ) -> OsString {
801
+ OsString :: from_inner ( self . inner . to_ascii_uppercase ( ) )
802
+ }
803
+
804
+ /// Checks if all characters in this string are within the ASCII range.
805
+ ///
806
+ /// # Examples
807
+ ///
808
+ /// ```
809
+ /// #![feature(osstring_ascii)]
810
+ /// use std::ffi::OsString;
811
+ ///
812
+ /// let ascii = OsString::from("hello!\n");
813
+ /// let non_ascii = OsString::from("Grüße, Jürgen ❤");
814
+ ///
815
+ /// assert!(ascii.is_ascii());
816
+ /// assert!(!non_ascii.is_ascii());
817
+ /// ```
818
+ #[ unstable( feature = "osstring_ascii" , issue = "70516" ) ]
819
+ pub fn is_ascii ( & self ) -> bool {
820
+ self . inner . is_ascii ( )
821
+ }
822
+
823
+ /// Checks that two strings are an ASCII case-insensitive match.
824
+ ///
825
+ /// Same as `to_ascii_lowercase(a) == to_ascii_lowercase(b)`,
826
+ /// but without allocating and copying temporaries.
827
+ ///
828
+ /// # Examples
829
+ ///
830
+ /// ```
831
+ /// #![feature(osstring_ascii)]
832
+ /// use std::ffi::OsString;
833
+ ///
834
+ /// assert!(OsString::from("Ferris").eq_ignore_ascii_case("FERRIS"));
835
+ /// assert!(OsString::from("Ferrös").eq_ignore_ascii_case("FERRöS"));
836
+ /// assert!(!OsString::from("Ferrös").eq_ignore_ascii_case("FERRÖS"));
837
+ /// ```
838
+ #[ unstable( feature = "osstring_ascii" , issue = "70516" ) ]
839
+ pub fn eq_ignore_ascii_case < S : ?Sized + AsRef < OsStr > > ( & self , other : & S ) -> bool {
840
+ self . inner . eq_ignore_ascii_case ( & other. as_ref ( ) . inner )
841
+ }
701
842
}
702
843
703
844
#[ stable( feature = "box_from_os_str" , since = "1.17.0" ) ]
0 commit comments