fix bytes stuff - STILL NEED TO FIX TESTS
This commit is contained in:
parent
7111192081
commit
9fac0f3667
3 changed files with 31 additions and 16 deletions
20
src/core.rs
20
src/core.rs
|
|
@ -135,3 +135,23 @@ pub fn char_length(base: u32) -> u32 {
|
|||
}
|
||||
return u32::MAX;
|
||||
}
|
||||
|
||||
pub mod bytes {
|
||||
/// Returns the minimum catspeak words per character needed for this base for bytes
|
||||
///
|
||||
/// ```
|
||||
/// use cat2text::core::bytes::char_length;
|
||||
///
|
||||
/// let base = 16;
|
||||
/// assert_eq!(char_length(base), 2)
|
||||
/// ```
|
||||
pub fn char_length(base: u32) -> u32 {
|
||||
for i in 1..base + 1 {
|
||||
let num = base.pow(i);
|
||||
if num > 255 {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return u32::MAX;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue