This commit is contained in:
Rorik Star Platinum 2025-12-15 00:04:32 +03:00
parent ed09dd5590
commit d5f25bd8bf
7 changed files with 276 additions and 0 deletions

14
rust/proverb/src/lib.rs Normal file
View file

@ -0,0 +1,14 @@
pub fn build_proverb(list: &[&str]) -> String {
if list.is_empty() {
return String::new();
}
list.windows(2)
.map(|pair| format!("For want of a {} the {} was lost.", pair[0], pair[1]))
.chain(std::iter::once(format!(
"And all for the want of a {}.",
list[0]
)))
.collect::<Vec<_>>()
.join("\n")
}