Rust - WIP run-length-encoding
This commit is contained in:
parent
030aecba88
commit
1659c90a27
1 changed files with 5 additions and 3 deletions
|
@ -10,12 +10,14 @@ pub fn encode(inp_string: &'static str) -> String{
|
|||
}
|
||||
|
||||
// Tokenizes a to-be-encoded string
|
||||
fn tokenize(inp_string: &'static str) -> Vec<&str>{
|
||||
return vec!["AAA","BB","C", "DDDD"]
|
||||
fn tokenize(inp_string: &'static str) -> Vec<String>{
|
||||
|
||||
|
||||
vec![String::from("AAA"), String::from("BB"), String::from("C"), String::from("DDDD")]
|
||||
}
|
||||
|
||||
// "Tuple-izes" a to-be-encoded vector
|
||||
fn tupleize(inp_vec: Vec<&str>) -> Vec<(char, usize)>{
|
||||
fn tupleize(inp_vec: Vec<String>) -> Vec<(char, usize)>{
|
||||
let mut tupleized: Vec<(char, usize)> = Vec::new();
|
||||
for each in inp_vec {
|
||||
tupleized.push((each.chars().next().unwrap(), each.len()));
|
||||
|
|
Loading…
Add table
Reference in a new issue