Convert tuple struct into regular struct

This commit is contained in:
Hanno Braun 2023-05-02 11:42:40 +02:00
parent 397e655b6e
commit 10aeba2696

View File

@ -10,18 +10,20 @@ use super::State;
/// Errors that occurred while validating the objects inserted into the stores /// Errors that occurred while validating the objects inserted into the stores
#[derive(Default)] #[derive(Default)]
pub struct Validation(BTreeMap<ObjectId, ValidationError>); pub struct Validation {
errors: BTreeMap<ObjectId, ValidationError>,
}
impl Drop for Validation { impl Drop for Validation {
fn drop(&mut self) { fn drop(&mut self) {
let num_errors = self.0.len(); let num_errors = self.errors.len();
if num_errors > 0 { if num_errors > 0 {
println!( println!(
"Dropping `Validation` with {num_errors} unhandled validation \ "Dropping `Validation` with {num_errors} unhandled validation \
errors:" errors:"
); );
for err in self.0.values() { for err in self.errors.values() {
println!("{}", err); println!("{}", err);
} }
@ -51,7 +53,7 @@ impl State for Validation {
} }
fn evolve(&mut self, event: &Self::Event) { fn evolve(&mut self, event: &Self::Event) {
self.0.insert(event.object.id(), event.err.clone()); self.errors.insert(event.object.id(), event.err.clone());
} }
} }