Skip to content

Commit 8fbd5ac

Browse files
committed
core: Add str::is_alphanumeric fn and method
1 parent 0746190 commit 8fbd5ac

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/libcore/str.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,15 @@ fn is_whitespace(s: str) -> bool {
11691169
ret all(s, char::is_whitespace);
11701170
}
11711171

1172+
#[doc = "
1173+
Returns true if the string contains only alphanumerics
1174+
1175+
Alphanumeric characters are determined by `char::is_alphanumeric`
1176+
"]
1177+
fn is_alphanumeric(s: str) -> bool {
1178+
ret all(s, char::is_alphanumeric);
1179+
}
1180+
11721181
#[doc = "
11731182
Returns the string length/size in bytes not counting the null terminator
11741183
"]
@@ -1833,6 +1842,13 @@ impl extensions for str {
18331842
"]
18341843
#[inline]
18351844
fn is_whitespace() -> bool { is_whitespace(self) }
1845+
#[doc = "
1846+
Returns true if the string contains only alphanumerics
1847+
1848+
Alphanumeric characters are determined by `char::is_alphanumeric`
1849+
"]
1850+
#[inlune]
1851+
fn is_alphanumeric() -> bool { is_alphanumeric(self) }
18361852
#[inline]
18371853
#[doc ="Returns the size in bytes not counting the null terminator"]
18381854
fn len() -> uint { len(self) }

0 commit comments

Comments
 (0)