Last active
April 6, 2022 07:27
-
-
Save upbeta01/a1e94c1e565fba66f6bb56968de97725 to your computer and use it in GitHub Desktop.
RustLang: 12 Days of Christmas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File: main.rs | |
fn main() { | |
// This code prints the lyrics of the song: "The Twelve Days of Christmas" | |
// Sing with me with these lines of code! | |
let mut count = 0; | |
let mut item_checkout: Vec<&str> = Vec::new(); | |
let days: [&str; 12] = [ | |
"1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", | |
]; | |
let items: [&str; 12] = [ | |
"A partridge in a pear tree", | |
"Two turtle-doves", | |
"Three French hens", | |
"Four calling birds", | |
"Five golden rings", | |
"Six geese a laying", | |
"Seven swans a swimming", | |
"Eight maids a milking", | |
"Nine ladies dancing", | |
"Ten lords a-leaping", | |
"Eleven pipers piping", | |
"Twelve drummers drumming", | |
]; | |
for day in days { | |
item_checkout.insert(0, items[count]); | |
count += 1; | |
println!("In the {} of Christmas, my true love sent to me..", day); | |
println!("\t{:?} \n", item_checkout); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment