char.rs: Added a function cmp
This commit is contained in:
parent
07ffe68ad9
commit
07574363ef
1 changed files with 8 additions and 0 deletions
|
|
@ -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 }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue