From 26667cddb857a21522b49b5ac83228b2a72a353a Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 24 Jul 2022 20:32:33 +0200 Subject: perf: use ahash in DI container --- src/di_container.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/di_container.rs b/src/di_container.rs index ae6a851..40de948 100644 --- a/src/di_container.rs +++ b/src/di_container.rs @@ -1,8 +1,8 @@ use std::any::{type_name, TypeId}; -use std::collections::HashMap; use std::marker::PhantomData; use std::rc::Rc; +use ahash::AHashMap; use error_stack::{Report, ResultExt}; #[cfg(feature = "factory")] @@ -119,7 +119,7 @@ where /// ``` pub struct DIContainer { - bindings: HashMap>, + bindings: AHashMap>, } impl DIContainer @@ -129,7 +129,7 @@ impl DIContainer pub fn new() -> Self { Self { - bindings: HashMap::new(), + bindings: AHashMap::new(), } } @@ -260,6 +260,7 @@ mod tests use super::*; use crate::errors::injectable::ResolveError; + use crate::ptr::InterfacePtr; #[test] fn can_bind_to() @@ -344,7 +345,8 @@ mod tests } } - type IUserManagerFactory = dyn IFactory<(), dyn IUserManager>; + type IUserManagerFactory = + dyn crate::interfaces::factory::IFactory<(), dyn IUserManager>; let mut di_container: DIContainer = DIContainer::new(); @@ -471,7 +473,8 @@ mod tests use crate as syrette; #[crate::factory] - type IUserManagerFactory = dyn IFactory<(Vec,), dyn IUserManager>; + type IUserManagerFactory = + dyn crate::interfaces::factory::IFactory<(Vec,), dyn IUserManager>; mock! { Provider {} -- cgit v1.2.3-18-g5258