diff options
| author | David Rajchenbach-Teller <dteller@mozilla.com> | 2011-11-04 14:33:11 +0100 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-11-05 13:04:34 -0700 |
| commit | 07574363efc8fa046d197c71a53ac9987c064902 (patch) | |
| tree | 0b2f72183f9bad336c5209213ef1eb79fb402544 /src | |
| parent | 07ffe68ad9145a209725ac289f8c4235b4c9b334 (diff) | |
| download | rust-07574363efc8fa046d197c71a53ac9987c064902.tar.gz rust-07574363efc8fa046d197c71a53ac9987c064902.zip | |
char.rs: Added a function cmp
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/char.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/char.rs b/src/lib/char.rs index 28345fb19fe..0af3b0d1a91 100644 --- a/src/lib/char.rs +++ b/src/lib/char.rs @@ -94,6 +94,7 @@ pure fn is_whitespace(c: char) -> bool { } else if c == ch_no_break_space { true } else { false } } + pure fn to_digit(c: char) -> u8 { alt c { '0' to '9' { c as u8 - ('0' as u8) } @@ -102,3 +103,10 @@ pure fn to_digit(c: char) -> u8 { _ { fail; } } } + + +fn cmp(a: char, b: char) -> int { + ret if b > a { -1 } + else if b < a { 1 } + else { 0 } +} \ No newline at end of file |
