|
|
@ -2,15 +2,10 @@ pub fn build_proverb(list: &[&str]) -> String { |
|
|
|
let mut verse = "".to_string();
|
|
|
|
|
|
|
|
if !list.is_empty() {
|
|
|
|
let nail = list.first().unwrap();
|
|
|
|
let mut prev = nail;
|
|
|
|
|
|
|
|
for i in 1..list.len() {
|
|
|
|
let next = list.get(i).unwrap();
|
|
|
|
verse.push_str(&format!("For want of a {} the {} was lost.\n", prev, next));
|
|
|
|
prev = next;
|
|
|
|
for item in list.windows(2) {
|
|
|
|
verse.push_str(&format!("For want of a {} the {} was lost.\n", item[0], item[1]));
|
|
|
|
}
|
|
|
|
verse.push_str(&format!("And all for the want of a {}.", nail));
|
|
|
|
verse.push_str(&format!("And all for the want of a {}.", list[0]));
|
|
|
|
}
|
|
|
|
|
|
|
|
verse
|
|
|
|