implement ToBase36 for u64; room id to u64; sprite id to u64; tile id to u64; sprite.dialogue -> sprite.dialogue_id

This commit is contained in:
2020-04-13 14:43:23 +01:00
parent f424c49301
commit c7f1d7220c
7 changed files with 48 additions and 37 deletions

View File

@@ -76,11 +76,22 @@ fn test_from_base36() {
assert_eq!(from_base36("11"), 37);
}
fn to_base36(input: u64) -> String {
format!("{}", radix_36(input))
/// this doesn't work inside ToBase36 for some reason
fn to_base36(int: u64) -> String {
format!("{}", radix_36(int))
}
pub trait ToBase36 {
fn to_base36(&self) -> String;
}
impl ToBase36 for u64 {
fn to_base36(&self) -> String {
to_base36(*self)
}
}
#[test]
fn test_to_base36() {
assert_eq!(to_base36(37), "11");
assert_eq!((37 as u64).to_base36(), "11");
}