Refactoring

This commit is contained in:
2025-09-09 07:39:16 +03:00
parent e7713f3529
commit c86be31d54
7 changed files with 87 additions and 39 deletions

View File

@@ -1,4 +1,3 @@
use crate::domain::author::Author;
use crate::domain::repository::{BookFilter, Repository};
use crate::domain::{author, book};
use std::collections::HashMap;
@@ -61,7 +60,7 @@ impl Into<book::Book> for Book {
pub struct BookRepository {
books: Vec<Book>,
authors: HashMap<Uuid, Author>,
authors: HashMap<Uuid, author::Author>,
author_uniques: HashMap<String, Uuid>,
}
@@ -110,10 +109,7 @@ impl Repository<book::Book, BookFilter> for BookRepository {
self.books.push(item.into());
}
fn bulk_add<I>(&mut self, items: I)
where
I: IntoIterator<Item = book::Book>,
{
fn bulk_add(&mut self, items: Vec<book::Book>) {
items.into_iter().for_each(|item| {
if self.get(item.id.to_string()).is_none() {
self.add(item)