rename EveryDay into AllDays

This commit is contained in:
Tristan Guichaoua 2023-11-22 13:00:21 +01:00
parent e73285f657
commit 94c5a487cc
2 changed files with 16 additions and 10 deletions

View file

@ -2,7 +2,6 @@ use std::error::Error;
use std::fmt::Display; use std::fmt::Display;
use std::str::FromStr; use std::str::FromStr;
/// A valid day number of advent (i.e. an integer in range 1 to 25). /// A valid day number of advent (i.e. an integer in range 1 to 25).
/// ///
/// # Display /// # Display
@ -82,16 +81,23 @@ impl Display for DayFromStrError {
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/// An iterator that yields every day of advent from the 1st to the 25th. /// An iterator that yields every day of advent from the 1st to the 25th.
pub fn every_day() -> EveryDay { pub fn all_days() -> AllDays {
EveryDay { current: 1 } AllDays::new()
} }
/// An iterator that yield every day of advent from the 1st to the 25th. /// An iterator that yields every day of advent from the 1st to the 25th.
pub struct EveryDay { pub struct AllDays {
current: u8, current: u8,
} }
impl Iterator for EveryDay { impl AllDays {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self { current: 1 }
}
}
impl Iterator for AllDays {
type Item = Day; type Item = Day;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
@ -128,11 +134,11 @@ macro_rules! day {
#[cfg(feature = "test_lib")] #[cfg(feature = "test_lib")]
mod tests { mod tests {
use super::{every_day, Day}; use super::{all_days, Day};
#[test] #[test]
fn every_day_iterator() { fn every_day_iterator() {
let mut iter = every_day(); let mut iter = all_days();
assert_eq!(iter.next(), Some(Day(1))); assert_eq!(iter.next(), Some(Day(1)));
assert_eq!(iter.next(), Some(Day(2))); assert_eq!(iter.next(), Some(Day(2)));

View file

@ -4,12 +4,12 @@ use crate::template::{
readme_benchmarks::{self, Timings}, readme_benchmarks::{self, Timings},
ANSI_BOLD, ANSI_ITALIC, ANSI_RESET, ANSI_BOLD, ANSI_ITALIC, ANSI_RESET,
}; };
use crate::{every_day, Day}; use crate::{all_days, Day};
pub fn handle(is_release: bool, is_timed: bool) { pub fn handle(is_release: bool, is_timed: bool) {
let mut timings: Vec<Timings> = vec![]; let mut timings: Vec<Timings> = vec![];
every_day().for_each(|day| { all_days().for_each(|day| {
if day > 1 { if day > 1 {
println!(); println!();
} }