Skip to content

Commit

Permalink
Rename hex_to_dec to hex_to_int
Browse files Browse the repository at this point in the history
  • Loading branch information
James Sanderson authored and James Sanderson committed Feb 15, 2015
1 parent 41cd445 commit 8e80407
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/hex.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub fn hex_to_dec(hex: char) -> int {
pub fn hex_to_int(hex: char) -> int {
if hex >= '0' && hex <= '9' {
hex as int - '0' as int
}
Expand All @@ -14,18 +14,18 @@ pub fn hex_to_dec(hex: char) -> int {
fn all_hexes() {
let hexes = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
for i in range(0u, hexes.len()) {
assert_eq!(hex_to_dec(hexes[i]), i as int);
assert_eq!(hex_to_int(hexes[i]), i as int);
}
}

#[test]
#[should_fail]
fn test_too_large() {
hex_to_dec('g');
hex_to_int('g');
}

#[test]
#[should_fail]
fn test_too_small() {
hex_to_dec('/');
}
hex_to_int('/');
}
2 changes: 1 addition & 1 deletion src/hex_to_base64.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod hex;

fn main() {
println!("Output: {}", hex::hex_to_dec('0'));
println!("Output: {}", hex::hex_to_int('0'));
}

0 comments on commit 8e80407

Please sign in to comment.