File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -2122,6 +2122,48 @@ impl str {
21222122 unsafe { String :: from_utf8_unchecked ( buf) }
21232123 }
21242124
2125+ /// Returns true if this `str` is entirely whitespace, and false otherwise.
2126+ ///
2127+ /// 'Whitespace' is defined according to the terms of the Unicode Derived Core
2128+ /// Property `White_Space`.
2129+ ///
2130+ /// # Examples
2131+ ///
2132+ /// Basic usage:
2133+ ///
2134+ /// ```
2135+ /// assert!(" \t ".is_whitespace());
2136+ ///
2137+ /// // a non-breaking space
2138+ /// assert!("\u{A0}".is_whitespace());
2139+ ///
2140+ /// assert!(!" 越".is_whitespace());
2141+ /// ```
2142+ #[ stable( feature = "unicode_methods_on_intrinsics" , since = "1.27.0" ) ]
2143+ #[ inline]
2144+ pub fn is_whitespace ( & self ) -> bool {
2145+ UnicodeStr :: is_whitespace ( self )
2146+ }
2147+
2148+ /// Returns true if this `str` is entirely alphanumeric, and false otherwise.
2149+ ///
2150+ /// 'Alphanumeric'-ness is defined in terms of the Unicode General Categories
2151+ /// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
2152+ ///
2153+ /// # Examples
2154+ ///
2155+ /// Basic usage:
2156+ ///
2157+ /// ```
2158+ /// assert!("٣7৬Kو藏".is_alphanumeric());
2159+ /// assert!(!"¾①".is_alphanumeric());
2160+ /// ```
2161+ #[ stable( feature = "unicode_methods_on_intrinsics" , since = "1.27.0" ) ]
2162+ #[ inline]
2163+ pub fn is_alphanumeric ( & self ) -> bool {
2164+ UnicodeStr :: is_alphanumeric ( self )
2165+ }
2166+
21252167 /// Checks if all characters in this string are within the ASCII range.
21262168 ///
21272169 /// # Examples
You can’t perform that action at this time.
0 commit comments