Pure Programmer
Blue Matrix


Cluster Map

Project: Twelve Days of Christmas Lyrics

Compute the full lyrics to the song Twelve Days of Christmas. Write a function to print a verse given the verse number. Use an array to hold the unique parts of each verse.

See [[The Twelve Days of Christmas (song)]]

Output
$ rustc TwelveDaysOfChristmasLyrics.rs error[E0277]: the type `[&'static str]` cannot be indexed by `isize` --> TwelveDaysOfChristmasLyrics.rs:14:49 | 14 | print!("On the {} day of Christmas ", ordinals[num - 1]); | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[&'static str]>` is not implemented for `isize` = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required for `Vec<&'static str>` to implement `Index<isize>` error[E0277]: the type `[&'static str]` cannot be indexed by `isize` --> TwelveDaysOfChristmasLyrics.rs:25:29 | 25 | println!("{},", phrases[i]); | ^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[&'static str]>` is not implemented for `isize` = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required for `Vec<&'static str>` to implement `Index<isize>` error[E0308]: mismatched types --> TwelveDaysOfChristmasLyrics.rs:36:14 | 36 | while i <= phrases.len() { | - ^^^^^^^^^^^^^ expected `isize`, found `usize` | | | expected because this is `isize` | help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit | 36 | while i <= phrases.len().try_into().unwrap() { | ++++++++++++++++++++ error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`.

Solution