Replace as many Box<dyn Trait> with generics as possible #32

Merged
wojtek merged 7 commits from 31---replace-as-many-Box-dyn-trait-with-generics-as-possible into main 2023-04-13 15:29:14 +02:00
Showing only changes of commit f58ffb036a - Show all commits

View File

@ -56,15 +56,15 @@ pub trait CollectionManager {
/// The collection manager. It is responsible for pulling information from both the library and the
/// database, ensuring its consistent and writing back any changes.
pub struct MhCollectionManager<L, D> {
library: L,
database: D,
pub struct MhCollectionManager<LIB, DB> {
library: LIB,
database: DB,
collection: Collection,
}
impl<L: Library, D: Database> MhCollectionManager<L, D> {
impl<LIB: Library, DB: Database> MhCollectionManager<LIB, DB> {
/// Create a new [`CollectionManager`] with the provided [`Library`] and [`Database`].
pub fn new(library: L, database: D) -> Self {
pub fn new(library: LIB, database: DB) -> Self {
MhCollectionManager {
library,
database,
@ -73,7 +73,7 @@ impl<L: Library, D: Database> MhCollectionManager<L, D> {
}
}
impl<L: Library, D: Database> CollectionManager for MhCollectionManager<L, D> {
impl<LIB: Library, DB: Database> CollectionManager for MhCollectionManager<LIB, DB> {
fn rescan_library(&mut self) -> Result<(), Error> {
self.collection = self.library.list(&Query::default())?;
Ok(())