This commit is contained in:
Simon Gardling 2022-03-29 11:19:01 -04:00
parent f9e523f320
commit 734989f1a4
2 changed files with 6 additions and 9 deletions

View File

@ -335,7 +335,7 @@ pub fn common_substring<'a>(a: &'a str, b: &'a str) -> Option<String> {
Some(last_value)
}
pub fn chars_take(chars: &Vec<char>, i: usize) -> String {
pub fn chars_take(chars: &[char], i: usize) -> String {
if i > chars.len() {
panic!("chars_take: i is larget than chars.len()");
}

View File

@ -26,7 +26,7 @@ pub fn generate_hint(input: &str) -> String {
let result_five = get_completion(chars_take(&chars, 5));
if let Some(output) = result_five {
return output.to_owned();
return output;
}
}
@ -34,7 +34,7 @@ pub fn generate_hint(input: &str) -> String {
let result_four = get_completion(chars_take(&chars, 4));
if let Some(output) = result_four {
return output.to_owned();
return output;
}
}
@ -42,14 +42,14 @@ pub fn generate_hint(input: &str) -> String {
let result_three = get_completion(chars_take(&chars, 3));
if let Some(output) = result_three {
return output.to_owned();
return output;
}
}
if len >= 2 {
let result_two = get_completion(chars_take(&chars, 2));
if let Some(output) = result_two {
return output.to_owned();
return output;
}
}
@ -214,10 +214,7 @@ mod tests {
for (key, value) in manual_values {
values.insert(
key.to_string(),
match value {
Some(x) => Some(x.to_string()),
None => None,
},
value.map(|x| x.to_string()),
);
}