Search lyrics or song metadata from your terminal
genius genius-lyrics-search genius-lyrics cli rust

Fix code review issues - correct random range and improve comments

- Change print_song_info() range from 0..5 to 0..6 to make case 5 reachable
- Add detailed comments explaining why all fields are needed in API structs
- Re-add #[allow(dead_code)] with explanation for deserialization requirements

Co-authored-by: jchoi2x <2028917+jchoi2x@users.noreply.github.com>

+5 -2
+5 -2
src/main.rs
··· 10 use rand::Rng; 11 use serde::Deserialize; 12 13 #[allow(dead_code)] 14 #[derive(Debug, Deserialize)] 15 struct LyricsApiResponse { ··· 17 id: u32, 18 title: String, 19 #[serde(default)] 20 - artist_names: String, 21 url: String, 22 lyrics: String, 23 primary_artist: ApiPrimaryArtist, ··· 34 35 fn print_song_info(artist_name: &str, title: &str, url: &str) { 36 let mut rng = rand::thread_rng(); 37 - match rng.gen_range(0..5) { 38 0 => { 39 println!( 40 "\n{}{}{}",
··· 10 use rand::Rng; 11 use serde::Deserialize; 12 13 + // API response structure from https://genius-mcp.xvzf.workers.dev/api/song/{id}/lyrics 14 + // All fields are part of the API response and need to be present for deserialization 15 + // Some fields aren't directly used in the code but are required for proper JSON parsing 16 #[allow(dead_code)] 17 #[derive(Debug, Deserialize)] 18 struct LyricsApiResponse { ··· 20 id: u32, 21 title: String, 22 #[serde(default)] 23 + artist_names: String, // Alternative to primary_artist.name 24 url: String, 25 lyrics: String, 26 primary_artist: ApiPrimaryArtist, ··· 37 38 fn print_song_info(artist_name: &str, title: &str, url: &str) { 39 let mut rng = rand::thread_rng(); 40 + match rng.gen_range(0..6) { 41 0 => { 42 println!( 43 "\n{}{}{}",