reinhardt_di/
factory_output.rs1use crate::InjectableKey;
4use std::marker::PhantomData;
5use std::ops::Deref;
6
7#[derive(Clone, Debug, PartialEq, Eq)]
11pub struct FactoryOutput<K, T>
12where
13 K: InjectableKey,
14 T: Send + Sync + 'static,
15{
16 value: T,
17 _key: PhantomData<fn() -> K>,
18}
19
20impl<K, T> FactoryOutput<K, T>
21where
22 K: InjectableKey,
23 T: Send + Sync + 'static,
24{
25 pub fn new(value: T) -> Self {
27 Self {
28 value,
29 _key: PhantomData,
30 }
31 }
32
33 pub fn into_inner(self) -> T {
35 self.value
36 }
37}
38
39impl<K, T> Deref for FactoryOutput<K, T>
40where
41 K: InjectableKey,
42 T: Send + Sync + 'static,
43{
44 type Target = T;
45
46 fn deref(&self) -> &Self::Target {
47 &self.value
48 }
49}
50
51impl<K, T> AsRef<T> for FactoryOutput<K, T>
52where
53 K: InjectableKey,
54 T: Send + Sync + 'static,
55{
56 fn as_ref(&self) -> &T {
57 &self.value
58 }
59}