@@ -1361,7 +1361,7 @@ pub pure fn is_whitespace(s: &str) -> bool {
1361
1361
*
1362
1362
* Alphanumeric characters are determined by `char::is_alphanumeric`
1363
1363
*/
1364
- fn is_alphanumeric ( s : & str ) -> bool {
1364
+ pure fn is_alphanumeric ( s : & str ) -> bool {
1365
1365
return all ( s, char:: is_alphanumeric) ;
1366
1366
}
1367
1367
@@ -2030,22 +2030,22 @@ pub mod raw {
2030
2030
}
2031
2031
2032
2032
pub trait UniqueStr {
2033
- fn trim ( ) -> self ;
2034
- fn trim_left ( ) -> self ;
2035
- fn trim_right ( ) -> self ;
2033
+ pure fn trim ( ) -> self ;
2034
+ pure fn trim_left ( ) -> self ;
2035
+ pure fn trim_right ( ) -> self ;
2036
2036
}
2037
2037
2038
2038
/// Extension methods for strings
2039
2039
impl ~str : UniqueStr {
2040
2040
/// Returns a string with leading and trailing whitespace removed
2041
2041
#[ inline]
2042
- fn trim ( ) -> ~str { trim ( self ) }
2042
+ pure fn trim ( ) -> ~str { trim ( self ) }
2043
2043
/// Returns a string with leading whitespace removed
2044
2044
#[ inline]
2045
- fn trim_left ( ) -> ~str { trim_left ( self ) }
2045
+ pure fn trim_left ( ) -> ~str { trim_left ( self ) }
2046
2046
/// Returns a string with trailing whitespace removed
2047
2047
#[ inline]
2048
- fn trim_right ( ) -> ~str { trim_right ( self ) }
2048
+ pure fn trim_right ( ) -> ~str { trim_right ( self ) }
2049
2049
}
2050
2050
2051
2051
#[ cfg( notest) ]
@@ -2062,33 +2062,33 @@ pub mod traits {
2062
2062
pub mod traits { }
2063
2063
2064
2064
pub trait StrSlice {
2065
- fn all ( it : fn ( char ) -> bool ) -> bool ;
2066
- fn any ( it : fn ( char ) -> bool ) -> bool ;
2067
- fn contains ( needle : & a/str ) -> bool ;
2068
- fn contains_char ( needle : char ) -> bool ;
2069
- fn each ( it : fn ( u8 ) -> bool ) ;
2070
- fn eachi ( it : fn ( uint , u8 ) -> bool ) ;
2071
- fn each_char ( it : fn ( char ) -> bool ) ;
2072
- fn each_chari ( it : fn ( uint , char ) -> bool ) ;
2073
- fn ends_with ( needle : & str ) -> bool ;
2074
- fn is_empty ( ) -> bool ;
2075
- fn is_not_empty ( ) -> bool ;
2076
- fn is_whitespace ( ) -> bool ;
2077
- fn is_alphanumeric ( ) -> bool ;
2065
+ pure fn all ( it : fn ( char ) -> bool ) -> bool ;
2066
+ pure fn any ( it : fn ( char ) -> bool ) -> bool ;
2067
+ pure fn contains ( needle : & a/str ) -> bool ;
2068
+ pure fn contains_char ( needle : char ) -> bool ;
2069
+ pure fn each ( it : fn ( u8 ) -> bool ) ;
2070
+ pure fn eachi ( it : fn ( uint , u8 ) -> bool ) ;
2071
+ pure fn each_char ( it : fn ( char ) -> bool ) ;
2072
+ pure fn each_chari ( it : fn ( uint , char ) -> bool ) ;
2073
+ pure fn ends_with ( needle : & str ) -> bool ;
2074
+ pure fn is_empty ( ) -> bool ;
2075
+ pure fn is_not_empty ( ) -> bool ;
2076
+ pure fn is_whitespace ( ) -> bool ;
2077
+ pure fn is_alphanumeric ( ) -> bool ;
2078
2078
pure fn len ( ) -> uint ;
2079
2079
pure fn slice ( begin : uint , end : uint ) -> ~str ;
2080
- fn split ( sepfn : fn ( char ) -> bool ) -> ~[ ~str ] ;
2081
- fn split_char ( sep : char ) -> ~[ ~str ] ;
2082
- fn split_str ( sep : & a/str ) -> ~[ ~str ] ;
2083
- fn starts_with ( needle : & a/str ) -> bool ;
2084
- fn substr ( begin : uint , n : uint ) -> ~str ;
2080
+ pure fn split ( sepfn : fn ( char ) -> bool ) -> ~[ ~str ] ;
2081
+ pure fn split_char ( sep : char ) -> ~[ ~str ] ;
2082
+ pure fn split_str ( sep : & a/str ) -> ~[ ~str ] ;
2083
+ pure fn starts_with ( needle : & a/str ) -> bool ;
2084
+ pure fn substr ( begin : uint , n : uint ) -> ~str ;
2085
2085
pure fn to_lower ( ) -> ~str ;
2086
2086
pure fn to_upper ( ) -> ~str ;
2087
- fn escape_default ( ) -> ~str ;
2088
- fn escape_unicode ( ) -> ~str ;
2089
- fn trim ( ) -> ~str ;
2090
- fn trim_left ( ) -> ~str ;
2091
- fn trim_right ( ) -> ~str ;
2087
+ pure fn escape_default ( ) -> ~str ;
2088
+ pure fn escape_unicode ( ) -> ~str ;
2089
+ pure fn trim ( ) -> ~str ;
2090
+ pure fn trim_left ( ) -> ~str ;
2091
+ pure fn trim_right ( ) -> ~str ;
2092
2092
pure fn to_unique ( ) -> ~str ;
2093
2093
pure fn char_at ( i : uint ) -> char ;
2094
2094
}
@@ -2100,54 +2100,56 @@ impl &str: StrSlice {
2100
2100
* contains no characters
2101
2101
*/
2102
2102
#[ inline]
2103
- fn all ( it : fn ( char ) -> bool ) -> bool { all ( self , it) }
2103
+ pure fn all ( it : fn ( char ) -> bool ) -> bool { all ( self , it) }
2104
2104
/**
2105
2105
* Return true if a predicate matches any character (and false if it
2106
2106
* matches none or there are no characters)
2107
2107
*/
2108
2108
#[ inline]
2109
- fn any ( it : fn ( char ) -> bool ) -> bool { any ( self , it) }
2109
+ pure fn any ( it : fn ( char ) -> bool ) -> bool { any ( self , it) }
2110
2110
/// Returns true if one string contains another
2111
2111
#[ inline]
2112
- fn contains ( needle : & a/str ) -> bool { contains ( self , needle) }
2112
+ pure fn contains ( needle : & a/str ) -> bool { contains ( self , needle) }
2113
2113
/// Returns true if a string contains a char
2114
2114
#[ inline]
2115
- fn contains_char ( needle : char ) -> bool { contains_char ( self , needle) }
2115
+ pure fn contains_char ( needle : char ) -> bool {
2116
+ contains_char ( self , needle)
2117
+ }
2116
2118
/// Iterate over the bytes in a string
2117
2119
#[ inline]
2118
- fn each ( it : fn ( u8 ) -> bool ) { each ( self , it) }
2120
+ pure fn each ( it : fn ( u8 ) -> bool ) { each ( self , it) }
2119
2121
/// Iterate over the bytes in a string, with indices
2120
2122
#[ inline]
2121
- fn eachi ( it : fn ( uint , u8 ) -> bool ) { eachi ( self , it) }
2123
+ pure fn eachi ( it : fn ( uint , u8 ) -> bool ) { eachi ( self , it) }
2122
2124
/// Iterate over the chars in a string
2123
2125
#[ inline]
2124
- fn each_char ( it : fn ( char ) -> bool ) { each_char ( self , it) }
2126
+ pure fn each_char ( it : fn ( char ) -> bool ) { each_char ( self , it) }
2125
2127
/// Iterate over the chars in a string, with indices
2126
2128
#[ inline]
2127
- fn each_chari ( it : fn ( uint , char ) -> bool ) { each_chari ( self , it) }
2129
+ pure fn each_chari ( it : fn ( uint , char ) -> bool ) { each_chari ( self , it) }
2128
2130
/// Returns true if one string ends with another
2129
2131
#[ inline]
2130
- fn ends_with ( needle : & str ) -> bool { ends_with ( self , needle) }
2132
+ pure fn ends_with ( needle : & str ) -> bool { ends_with ( self , needle) }
2131
2133
/// Returns true if the string has length 0
2132
2134
#[ inline]
2133
- fn is_empty ( ) -> bool { is_empty ( self ) }
2135
+ pure fn is_empty ( ) -> bool { is_empty ( self ) }
2134
2136
/// Returns true if the string has length greater than 0
2135
2137
#[ inline]
2136
- fn is_not_empty ( ) -> bool { is_not_empty ( self ) }
2138
+ pure fn is_not_empty ( ) -> bool { is_not_empty ( self ) }
2137
2139
/**
2138
2140
* Returns true if the string contains only whitespace
2139
2141
*
2140
2142
* Whitespace characters are determined by `char::is_whitespace`
2141
2143
*/
2142
2144
#[ inline]
2143
- fn is_whitespace ( ) -> bool { is_whitespace ( self ) }
2145
+ pure fn is_whitespace ( ) -> bool { is_whitespace ( self ) }
2144
2146
/**
2145
2147
* Returns true if the string contains only alphanumerics
2146
2148
*
2147
2149
* Alphanumeric characters are determined by `char::is_alphanumeric`
2148
2150
*/
2149
2151
#[ inline]
2150
- fn is_alphanumeric ( ) -> bool { is_alphanumeric ( self ) }
2152
+ pure fn is_alphanumeric ( ) -> bool { is_alphanumeric ( self ) }
2151
2153
#[ inline]
2152
2154
/// Returns the size in bytes not counting the null terminator
2153
2155
pure fn len ( ) -> uint { len ( self ) }
@@ -2162,29 +2164,29 @@ impl &str: StrSlice {
2162
2164
pure fn slice ( begin : uint , end : uint ) -> ~str { slice ( self , begin, end) }
2163
2165
/// Splits a string into substrings using a character function
2164
2166
#[ inline]
2165
- fn split ( sepfn : fn ( char ) -> bool ) -> ~[ ~str ] { split ( self , sepfn) }
2167
+ pure fn split ( sepfn : fn ( char ) -> bool ) -> ~[ ~str ] { split ( self , sepfn) }
2166
2168
/**
2167
2169
* Splits a string into substrings at each occurrence of a given character
2168
2170
*/
2169
2171
#[ inline]
2170
- fn split_char ( sep : char ) -> ~[ ~str ] { split_char ( self , sep) }
2172
+ pure fn split_char ( sep : char ) -> ~[ ~str ] { split_char ( self , sep) }
2171
2173
/**
2172
2174
* Splits a string into a vector of the substrings separated by a given
2173
2175
* string
2174
2176
*/
2175
2177
#[ inline]
2176
- fn split_str ( sep : & a/str ) -> ~[ ~str ] { split_str ( self , sep) }
2178
+ pure fn split_str ( sep : & a/str ) -> ~[ ~str ] { split_str ( self , sep) }
2177
2179
/// Returns true if one string starts with another
2178
2180
#[ inline]
2179
- fn starts_with ( needle : & a/str ) -> bool { starts_with ( self , needle) }
2181
+ pure fn starts_with ( needle : & a/str ) -> bool { starts_with ( self , needle) }
2180
2182
/**
2181
2183
* Take a substring of another.
2182
2184
*
2183
2185
* Returns a string containing `n` characters starting at byte offset
2184
2186
* `begin`.
2185
2187
*/
2186
2188
#[ inline]
2187
- fn substr ( begin : uint , n : uint ) -> ~str { substr ( self , begin, n) }
2189
+ pure fn substr ( begin : uint , n : uint ) -> ~str { substr ( self , begin, n) }
2188
2190
/// Convert a string to lowercase
2189
2191
#[ inline]
2190
2192
pure fn to_lower ( ) -> ~str { to_lower ( self ) }
@@ -2193,20 +2195,20 @@ impl &str: StrSlice {
2193
2195
pure fn to_upper ( ) -> ~str { to_upper ( self ) }
2194
2196
/// Escape each char in `s` with char::escape_default.
2195
2197
#[ inline]
2196
- fn escape_default ( ) -> ~str { escape_default ( self ) }
2198
+ pure fn escape_default ( ) -> ~str { escape_default ( self ) }
2197
2199
/// Escape each char in `s` with char::escape_unicode.
2198
2200
#[ inline]
2199
- fn escape_unicode ( ) -> ~str { escape_unicode ( self ) }
2201
+ pure fn escape_unicode ( ) -> ~str { escape_unicode ( self ) }
2200
2202
2201
2203
/// Returns a string with leading and trailing whitespace removed
2202
2204
#[ inline]
2203
- fn trim ( ) -> ~str { trim ( self ) }
2205
+ pure fn trim ( ) -> ~str { trim ( self ) }
2204
2206
/// Returns a string with leading whitespace removed
2205
2207
#[ inline]
2206
- fn trim_left ( ) -> ~str { trim_left ( self ) }
2208
+ pure fn trim_left ( ) -> ~str { trim_left ( self ) }
2207
2209
/// Returns a string with trailing whitespace removed
2208
2210
#[ inline]
2209
- fn trim_right ( ) -> ~str { trim_right ( self ) }
2211
+ pure fn trim_right ( ) -> ~str { trim_right ( self ) }
2210
2212
2211
2213
#[ inline]
2212
2214
pure fn to_unique ( ) -> ~str { self . slice ( 0 , self . len ( ) ) }
0 commit comments