aboutsummaryrefslogtreecommitdiff
path: root/src/di_container.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-07-24 20:32:33 +0200
committerHampusM <hampus@hampusmat.com>2022-07-24 20:32:33 +0200
commit26667cddb857a21522b49b5ac83228b2a72a353a (patch)
tree278c8f6c273d69b392428637f75aef74defc7d2f /src/di_container.rs
parent8a3822e6eff97575abc421e5030d937bacb42b65 (diff)
perf: use ahash in DI container
Diffstat (limited to 'src/di_container.rs')
-rw-r--r--src/di_container.rs13
1 files changed, 8 insertions, 5 deletions
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<TypeId, Rc<dyn IProvider>>,
+ bindings: AHashMap<TypeId, Rc<dyn IProvider>>,
}
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<i128>,), dyn IUserManager>;
+ type IUserManagerFactory =
+ dyn crate::interfaces::factory::IFactory<(Vec<i128>,), dyn IUserManager>;
mock! {
Provider {}