Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
char.rs: Added a function cmp
  • Loading branch information
Yoric authored and brson committed Nov 5, 2011
1 parent 07ffe68 commit 0757436
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/char.rs
Expand Up @@ -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) }
Expand All @@ -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 }
}

0 comments on commit 0757436

Please sign in to comment.