From 02481656966b0a8dfc95cf3c22bcc049660ff7d4 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Sat, 26 Dec 2020 17:48:38 +0000 Subject: Move Rust exercises in a subdirectory --- beer-song/src/lib.rs | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 beer-song/src/lib.rs (limited to 'beer-song/src/lib.rs') diff --git a/beer-song/src/lib.rs b/beer-song/src/lib.rs deleted file mode 100644 index 990fbbf..0000000 --- a/beer-song/src/lib.rs +++ /dev/null @@ -1,20 +0,0 @@ -use itertools::Itertools; - -pub fn verse(n: u32) -> String { - match n { - 0 => format!( "No more bottles of beer on the wall, no more bottles of beer.\n\ - Go to the store and buy some more, 99 bottles of beer on the wall.\n"), - 1 => format!( "1 bottle of beer on the wall, 1 bottle of beer.\n\ - Take it down and pass it around, no more bottles of beer on the wall.\n"), - 2 => format!( "2 bottles of beer on the wall, 2 bottles of beer.\n\ - Take one down and pass it around, 1 bottle of beer on the wall.\n"), - _ => format!( "{} bottles of beer on the wall, {} bottles of beer.\n\ - Take one down and pass it around, {} bottles of beer on the wall.\n", - n, n, n - 1) - } -} - -pub fn sing(start: u32, end: u32) -> String { - // Note: call to `join` can be substituted with `.intersperse(String::from("\n")).collect()` - (end..=start).rev().map(|x| verse(x)).join("\n") -} -- cgit v1.2.3