chore: format
This commit is contained in:
parent
4fc0cbc078
commit
5e315db651
3 changed files with 21 additions and 18 deletions
|
@ -104,7 +104,8 @@ pub mod bytes {
|
||||||
let mut shortened_alphabet = core::alphabet();
|
let mut shortened_alphabet = core::alphabet();
|
||||||
shortened_alphabet.truncate(base as usize);
|
shortened_alphabet.truncate(base as usize);
|
||||||
for byte in bytes.as_ref() {
|
for byte in bytes.as_ref() {
|
||||||
output += core::num_to_cat(*byte as u32, shortened_alphabet.clone(), char_length).as_str();
|
output +=
|
||||||
|
core::num_to_cat(*byte as u32, shortened_alphabet.clone(), char_length).as_str();
|
||||||
output += " ";
|
output += " ";
|
||||||
}
|
}
|
||||||
return output.trim().to_string();
|
return output.trim().to_string();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! This module handles base 4, like the original [Cat2Text](https://github.com/Evelyn3440/Cat2Text); it can translate either english text a-z, or byte arrays (see [`bytes`])
|
//! This module handles base 4, like the original [Cat2Text](https://github.com/Evelyn3440/Cat2Text); it can translate either english text a-z, or byte arrays (see [`bytes`])
|
||||||
use crate::core;
|
|
||||||
use crate::anybase;
|
use crate::anybase;
|
||||||
|
use crate::core;
|
||||||
|
|
||||||
/// Returns the alphabet used by `cat2text::base4`
|
/// Returns the alphabet used by `cat2text::base4`
|
||||||
pub fn alphabet() -> Vec<String> {
|
pub fn alphabet() -> Vec<String> {
|
||||||
|
@ -14,7 +14,6 @@ pub fn char_length() -> u32 {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Encodes english text into base 4 catspeak
|
/// Encodes english text into base 4 catspeak
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -34,13 +33,13 @@ pub fn encode(text: impl AsRef<str>) -> String {
|
||||||
/// assert_eq!("i love cats", decode("meow mreow mrrp; meow mrow meow meow mrow mrow mrrp mrrp mreow meow mrrp mrrp; meow meow mrow meow meow mrrp mrrp mrrp meow mrrp meow mrow".to_string()));
|
/// assert_eq!("i love cats", decode("meow mreow mrrp; meow mrow meow meow mrow mrow mrrp mrrp mreow meow mrrp mrrp; meow meow mrow meow meow mrrp mrrp mrrp meow mrrp meow mrow".to_string()));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn decode(text: String) -> String {
|
pub fn decode(text: String) -> String {
|
||||||
return anybase::decode(text, 4, char_length())
|
return anybase::decode(text, 4, char_length());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod bytes {
|
pub mod bytes {
|
||||||
//! This handles encoding and decoding bytes to/from catspeak
|
//! This handles encoding and decoding bytes to/from catspeak
|
||||||
use crate::anybase;
|
|
||||||
use super::char_length;
|
use super::char_length;
|
||||||
|
use crate::anybase;
|
||||||
/// Encodes from bytes into catspeak
|
/// Encodes from bytes into catspeak
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -81,7 +81,10 @@ pub(crate) fn split_every_x(text: String, x: u32) -> Vec<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim everything before sending it back
|
// trim everything before sending it back
|
||||||
output = output.into_iter().map(|item| item.trim().to_string()).collect();
|
output = output
|
||||||
|
.into_iter()
|
||||||
|
.map(|item| item.trim().to_string())
|
||||||
|
.collect();
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +98,7 @@ pub(crate) fn split_every_x(text: String, x: u32) -> Vec<String> {
|
||||||
pub fn alphabet() -> Vec<String> {
|
pub fn alphabet() -> Vec<String> {
|
||||||
return vec![
|
return vec![
|
||||||
"meow", "mrrp", "mreow", "mrow", "nya~", "nyaaaa~", "mraow", "mew", "prrp", "mewo",
|
"meow", "mrrp", "mreow", "mrow", "nya~", "nyaaaa~", "mraow", "mew", "prrp", "mewo",
|
||||||
"purrrr", "nya", "miao", "miau", "miauw", "mrow~"
|
"purrrr", "nya", "miao", "miau", "miauw", "mrow~",
|
||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|a| a.to_string())
|
.map(|a| a.to_string())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue