diff options
Diffstat (limited to 'src/castable_factory.rs')
-rw-r--r-- | src/castable_factory.rs | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/castable_factory.rs b/src/castable_factory.rs deleted file mode 100644 index 5ff4db0..0000000 --- a/src/castable_factory.rs +++ /dev/null @@ -1,74 +0,0 @@ -use crate::interfaces::any_factory::AnyFactory; -use crate::interfaces::factory::IFactory; -use crate::ptr::TransientPtr; - -pub struct CastableFactory<Args, ReturnInterface> -where - Args: 'static, - ReturnInterface: 'static + ?Sized, -{ - func: &'static dyn Fn<Args, Output = TransientPtr<ReturnInterface>>, -} - -impl<Args, ReturnInterface> CastableFactory<Args, ReturnInterface> -where - Args: 'static, - ReturnInterface: 'static + ?Sized, -{ - pub fn new( - func: &'static dyn Fn<Args, Output = TransientPtr<ReturnInterface>>, - ) -> Self - { - Self { func } - } -} - -impl<Args, ReturnInterface> IFactory<Args, ReturnInterface> - for CastableFactory<Args, ReturnInterface> -where - Args: 'static, - ReturnInterface: 'static + ?Sized, -{ -} - -impl<Args, ReturnInterface> Fn<Args> for CastableFactory<Args, ReturnInterface> -where - Args: 'static, - ReturnInterface: 'static + ?Sized, -{ - extern "rust-call" fn call(&self, args: Args) -> Self::Output - { - self.func.call(args) - } -} - -impl<Args, ReturnInterface> FnMut<Args> for CastableFactory<Args, ReturnInterface> -where - Args: 'static, - ReturnInterface: 'static + ?Sized, -{ - extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output - { - self.call(args) - } -} - -impl<Args, ReturnInterface> FnOnce<Args> for CastableFactory<Args, ReturnInterface> -where - Args: 'static, - ReturnInterface: 'static + ?Sized, -{ - type Output = TransientPtr<ReturnInterface>; - - extern "rust-call" fn call_once(self, args: Args) -> Self::Output - { - self.call(args) - } -} - -impl<Args, ReturnInterface> AnyFactory for CastableFactory<Args, ReturnInterface> -where - Args: 'static, - ReturnInterface: 'static + ?Sized, -{ -} |