Skip to content

Commit 2fa83c0

Browse files
committed
std: replace str::is_{alphanumeric,whitespace} with the methods.
1 parent 838191c commit 2fa83c0

File tree

3 files changed

+11
-29
lines changed

3 files changed

+11
-29
lines changed

src/librustdoc/desc_to_brief_pass.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub fn paragraphs(s: &str) -> ~[~str] {
151151
let paras = do lines.iter().fold(~[]) |paras, line| {
152152
let mut res = paras;
153153

154-
if str::is_whitespace(*line) {
154+
if line.is_whitespace() {
155155
whitespace_lines += 1;
156156
} else {
157157
if whitespace_lines > 0 {

src/librustdoc/unindent_pass.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn unindent(s: &str) -> ~str {
4646
let ignore_previous_indents =
4747
saw_first_line &&
4848
!saw_second_line &&
49-
!str::is_whitespace(*line);
49+
!line.is_whitespace();
5050

5151
let min_indent = if ignore_previous_indents {
5252
uint::max_value
@@ -58,7 +58,7 @@ fn unindent(s: &str) -> ~str {
5858
saw_second_line = true;
5959
}
6060

61-
if str::is_whitespace(*line) {
61+
if line.is_whitespace() {
6262
min_indent
6363
} else {
6464
saw_first_line = true;
@@ -80,7 +80,7 @@ fn unindent(s: &str) -> ~str {
8080
if !lines.is_empty() {
8181
let unindented = ~[lines.head().trim().to_owned()]
8282
+ do lines.tail().map |line| {
83-
if str::is_whitespace(*line) {
83+
if line.is_whitespace() {
8484
copy *line
8585
} else {
8686
assert!(line.len() >= min_indent);

src/libstd/str.rs

+7-25
Original file line numberDiff line numberDiff line change
@@ -981,24 +981,6 @@ fn match_at<'a,'b>(haystack: &'a str, needle: &'b str, at: uint) -> bool {
981981
Section: String properties
982982
*/
983983

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-
1002984
/// Returns the number of characters that a string holds
1003985
#[inline(always)]
1004986
pub fn char_len(s: &str) -> uint { count_chars(s, 0u, s.len()) }
@@ -1749,14 +1731,14 @@ impl<'self> StrSlice<'self> for &'self str {
17491731
* Whitespace characters are determined by `char::is_whitespace`
17501732
*/
17511733
#[inline]
1752-
fn is_whitespace(&self) -> bool { is_whitespace(*self) }
1734+
fn is_whitespace(&self) -> bool { self.iter().all(char::is_whitespace) }
17531735
/**
17541736
* Returns true if the string contains only alphanumerics
17551737
*
17561738
* Alphanumeric characters are determined by `char::is_alphanumeric`
17571739
*/
17581740
#[inline]
1759-
fn is_alphanumeric(&self) -> bool { is_alphanumeric(*self) }
1741+
fn is_alphanumeric(&self) -> bool { self.iter().all(char::is_alphanumeric) }
17601742
/// Returns the size in bytes not counting the null terminator
17611743
#[inline(always)]
17621744
fn len(&self) -> uint {
@@ -2773,11 +2755,11 @@ mod tests {
27732755

27742756
#[test]
27752757
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());
27812763
}
27822764

27832765
#[test]

0 commit comments

Comments
 (0)