@@ -698,6 +698,149 @@ impl OsStr {
698698 fn bytes ( & self ) -> & [ u8 ] {
699699 unsafe { & * ( & self . inner as * const _ as * const [ u8 ] ) }
700700 }
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 = "none" ) ]
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 = "none" ) ]
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+ /// # Examples
765+ ///
766+ /// ```
767+ /// #![feature(osstring_ascii)]
768+ /// use std::ffi::OsString;
769+ /// let s = OsString::from("Grüße, Jürgen ❤");
770+ ///
771+ /// assert_eq!("grüße, jürgen ❤", s.to_ascii_lowercase());
772+ /// ```
773+ ///
774+ /// [`make_ascii_lowercase`]: #method.make_ascii_lowercase
775+ #[ unstable( feature = "osstring_ascii" , issue = "none" ) ]
776+ pub fn to_ascii_lowercase ( & self ) -> OsString {
777+ // OsString::from_inner(Buf::from_inner(self.inner.inner.to_ascii_lowercase()))
778+ OsString :: from_inner ( self . inner . to_ascii_lowercase ( ) )
779+ }
780+
781+ /// Returns a copy of this string where each character is mapped to its
782+ /// ASCII upper case equivalent.
783+ ///
784+ /// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
785+ /// but non-ASCII letters are unchanged.
786+ ///
787+ /// To uppercase the value in-place, use [`make_ascii_uppercase`].
788+ ///
789+ /// # Examples
790+ ///
791+ /// ```
792+ /// #![feature(osstring_ascii)]
793+ /// use std::ffi::OsString;
794+ /// let s = OsString::from("Grüße, Jürgen ❤");
795+ ///
796+ /// assert_eq!("GRüßE, JüRGEN ❤", s.to_ascii_uppercase());
797+ /// ```
798+ ///
799+ /// [`make_ascii_uppercase`]: #method.make_ascii_uppercase
800+ #[ unstable( feature = "osstring_ascii" , issue = "none" ) ]
801+ pub fn to_ascii_uppercase ( & self ) -> OsString {
802+ // OsString::from_inner(Buf::from_inner(self.inner.inner.to_ascii_lowercase()))
803+ OsString :: from_inner ( self . inner . to_ascii_uppercase ( ) )
804+ }
805+
806+ /// Checks if all characters in this string are within the ASCII range.
807+ ///
808+ /// # Examples
809+ ///
810+ /// ```
811+ /// #![feature(osstring_ascii)]
812+ /// use std::ffi::OsString;
813+ ///
814+ /// let ascii = OsString::from("hello!\n");
815+ /// let non_ascii = OsString::from("Grüße, Jürgen ❤");
816+ ///
817+ /// assert!(ascii.is_ascii());
818+ /// assert!(!non_ascii.is_ascii());
819+ /// ```
820+ #[ unstable( feature = "osstring_ascii" , issue = "none" ) ]
821+ pub fn is_ascii ( & self ) -> bool {
822+ self . inner . is_ascii ( )
823+ }
824+
825+ /// Checks that two strings are an ASCII case-insensitive match.
826+ ///
827+ /// Same as `to_ascii_lowercase(a) == to_ascii_lowercase(b)`,
828+ /// but without allocating and copying temporaries.
829+ ///
830+ /// # Examples
831+ ///
832+ /// ```
833+ /// #![feature(osstring_ascii)]
834+ /// use std::ffi::OsString;
835+ ///
836+ /// assert!(OsString::from("Ferris").eq_ignore_ascii_case("FERRIS"));
837+ /// assert!(OsString::from("Ferrös").eq_ignore_ascii_case("FERRöS"));
838+ /// assert!(!OsString::from("Ferrös").eq_ignore_ascii_case("FERRÖS"));
839+ /// ```
840+ #[ unstable( feature = "osstring_ascii" , issue = "none" ) ]
841+ pub fn eq_ignore_ascii_case < S : ?Sized + AsRef < OsStr > > ( & self , other : & S ) -> bool {
842+ self . inner . eq_ignore_ascii_case ( & other. as_ref ( ) . inner )
843+ }
701844}
702845
703846#[ stable( feature = "box_from_os_str" , since = "1.17.0" ) ]
0 commit comments