use crate::bullet::Bullet; pub const TOKEN_DAY: char = '='; #[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)] pub struct Day { pub index: u8, pub bullets: Option>, } impl PartialOrd for Day { fn partial_cmp(&self, other: &Self) -> Option { Some(self.index.cmp(&other.index)) } } impl Day { pub fn title(&self) -> String { format!("{TOKEN_DAY}\t{}", self.index) } pub fn basic_format(&self) -> String { let first_line = format!("{}\n", self.title()); let Some(bullets) = &self.bullets else { return first_line; }; let bullets_formed = bullets .iter() .map(Bullet::basic_format) .collect::>() .join("\n"); format!("{first_line}{bullets_formed}") } }