Skip to content

Commit a5a02cb

Browse files
committed
---
yaml --- r: 81855 b: refs/heads/master c: df97d23 h: refs/heads/master i: 81853: dc8ab56 81851: 8c4171c 81847: 67a754b 81839: ed29963 81823: f92bd6d 81791: 32df69f v: v3
1 parent 83b1ea1 commit a5a02cb

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f6c9ff392becd86ee22ad96cd66e137b65195f97
2+
refs/heads/master: df97d23c71f6fbe300d3bc0dca23b063044b3934
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/src/libstd/char.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ pub fn is_alphanumeric(c: char) -> bool {
128128
|| general_category::No(c)
129129
}
130130

131+
///
132+
/// Indicates whether a character is a control character. Control
133+
/// characters are defined in terms of the Unicode General Category
134+
/// 'Cc'.
135+
///
136+
#[inline]
137+
pub fn is_control(c: char) -> bool { general_category::Cc(c) }
138+
131139
/// Indicates whether the character is numeric (Nd, Nl, or No)
132140
#[inline]
133141
pub fn is_digit(c: char) -> bool {
@@ -354,6 +362,7 @@ pub trait Char {
354362
fn is_uppercase(&self) -> bool;
355363
fn is_whitespace(&self) -> bool;
356364
fn is_alphanumeric(&self) -> bool;
365+
fn is_control(&self) -> bool;
357366
fn is_digit(&self) -> bool;
358367
fn is_digit_radix(&self, radix: uint) -> bool;
359368
fn to_digit(&self, radix: uint) -> Option<uint>;
@@ -384,6 +393,8 @@ impl Char for char {
384393

385394
fn is_alphanumeric(&self) -> bool { is_alphanumeric(*self) }
386395

396+
fn is_control(&self) -> bool { is_control(*self) }
397+
387398
fn is_digit(&self) -> bool { is_digit(*self) }
388399

389400
fn is_digit_radix(&self, radix: uint) -> bool { is_digit_radix(*self, radix) }
@@ -494,6 +505,19 @@ fn test_to_digit() {
494505
assert_eq!('$'.to_digit(36u), None);
495506
}
496507

508+
#[test]
509+
fn test_is_control() {
510+
assert!('\u0000'.is_control());
511+
assert!('\u0003'.is_control());
512+
assert!('\u0006'.is_control());
513+
assert!('\u0009'.is_control());
514+
assert!('\u007f'.is_control());
515+
assert!('\u0092'.is_control());
516+
assert!(!'\u0020'.is_control());
517+
assert!(!'\u0055'.is_control());
518+
assert!(!'\u0068'.is_control());
519+
}
520+
497521
#[test]
498522
fn test_is_digit() {
499523
assert!('2'.is_digit());

0 commit comments

Comments
 (0)