@@ -981,24 +981,6 @@ fn match_at<'a,'b>(haystack: &'a str, needle: &'b str, at: uint) -> bool {
981
981
Section: String properties
982
982
*/
983
983
984
- /**
985
- * Returns true if the string contains only whitespace
986
- *
987
- * Whitespace characters are determined by `char::is_whitespace`
988
- */
989
- pub fn is_whitespace ( s : & str ) -> bool {
990
- s. iter ( ) . all ( char:: is_whitespace)
991
- }
992
-
993
- /**
994
- * Returns true if the string contains only alphanumerics
995
- *
996
- * Alphanumeric characters are determined by `char::is_alphanumeric`
997
- */
998
- fn is_alphanumeric ( s : & str ) -> bool {
999
- s. iter ( ) . all ( char:: is_alphanumeric)
1000
- }
1001
-
1002
984
/// Returns the number of characters that a string holds
1003
985
#[ inline( always) ]
1004
986
pub fn char_len ( s : & str ) -> uint { count_chars ( s, 0 u, s. len ( ) ) }
@@ -1749,14 +1731,14 @@ impl<'self> StrSlice<'self> for &'self str {
1749
1731
* Whitespace characters are determined by `char::is_whitespace`
1750
1732
*/
1751
1733
#[inline]
1752
- fn is_whitespace(&self) -> bool { is_whitespace(* self) }
1734
+ fn is_whitespace(&self) -> bool { self.iter().all(char::is_whitespace ) }
1753
1735
/**
1754
1736
* Returns true if the string contains only alphanumerics
1755
1737
*
1756
1738
* Alphanumeric characters are determined by `char::is_alphanumeric`
1757
1739
*/
1758
1740
#[inline]
1759
- fn is_alphanumeric(&self) -> bool { is_alphanumeric(* self) }
1741
+ fn is_alphanumeric(&self) -> bool { self.iter().all(char::is_alphanumeric ) }
1760
1742
/// Returns the size in bytes not counting the null terminator
1761
1743
#[inline(always)]
1762
1744
fn len(&self) -> uint {
@@ -2773,11 +2755,11 @@ mod tests {
2773
2755
2774
2756
#[ test]
2775
2757
fn test_is_whitespace( ) {
2776
- assert!( is_whitespace ( "" ) ) ;
2777
- assert!( is_whitespace ( " " ) ) ;
2778
- assert!( is_whitespace ( "\u2009 " ) ) ; // Thin space
2779
- assert!( is_whitespace ( " \n \t " ) ) ;
2780
- assert!( !is_whitespace ( " _ " ) ) ;
2758
+ assert!( "" . is_whitespace ( ) ) ;
2759
+ assert!( " " . is_whitespace ( ) ) ;
2760
+ assert!( "\u2009 " . is_whitespace ( ) ) ; // Thin space
2761
+ assert!( " \n \t " . is_whitespace ( ) ) ;
2762
+ assert!( !" _ " . is_whitespace ( ) ) ;
2781
2763
}
2782
2764
2783
2765
#[ test]
0 commit comments