fish-lib 0.2.3

A work-in-progress fishing game library containing the game/storage logic for a discord fishing game I'm working on.
Documentation
use crate::config::validation_error::ConfigValidationError;
use std::fmt::{Display, Formatter};

#[derive(Debug, Default)]
pub struct ConfigValidationReport {
    errors: Vec<ConfigValidationError>,
}

impl ConfigValidationReport {
    pub fn new() -> Self {
        Self::default()
    }

    pub fn add_error(&mut self, error: ConfigValidationError) {
        self.errors.push(error);
    }

    pub fn has_errors(&self) -> bool {
        !self.errors.is_empty()
    }

    pub fn errors(&self) -> &[ConfigValidationError] {
        &self.errors
    }
}

impl Display for ConfigValidationReport {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        writeln!(f, "Found {} config validation errors:", self.errors.len())?;
        for (i, error) in self.errors.iter().enumerate() {
            writeln!(f, "[{}] {}", i + 1, error)?;
        }
        Ok(())
    }
}