From 1b27423ae2f2455c72cc7020051c861227aeeeb5 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 7 Nov 2022 21:01:10 +0100 Subject: fix: make factories work again after Rust nightly-2022-11-07 --- src/castable_factory/blocking.rs | 17 +++++++++-------- src/castable_factory/threadsafe.rs | 19 ++++++++++--------- src/di_container/asynchronous/binding/builder.rs | 4 ++-- src/di_container/blocking/binding/builder.rs | 2 +- src/interfaces/factory.rs | 4 ++++ src/lib.rs | 2 +- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/castable_factory/blocking.rs b/src/castable_factory/blocking.rs index 48f426d..f16d86a 100644 --- a/src/castable_factory/blocking.rs +++ b/src/castable_factory/blocking.rs @@ -1,5 +1,6 @@ use std::any::type_name; use std::fmt::Debug; +use std::marker::Tuple; use crate::interfaces::any_factory::AnyFactory; use crate::interfaces::factory::IFactory; @@ -7,7 +8,7 @@ use crate::ptr::TransientPtr; pub struct CastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { func: &'static dyn Fn>, @@ -15,7 +16,7 @@ where impl CastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { pub fn new( @@ -29,14 +30,14 @@ where impl IFactory for CastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { } impl Fn for CastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { extern "rust-call" fn call(&self, args: Args) -> Self::Output @@ -47,7 +48,7 @@ where impl FnMut for CastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output @@ -58,7 +59,7 @@ where impl FnOnce for CastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { type Output = TransientPtr; @@ -71,14 +72,14 @@ where impl AnyFactory for CastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { } impl Debug for CastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { #[cfg(not(tarpaulin_include))] diff --git a/src/castable_factory/threadsafe.rs b/src/castable_factory/threadsafe.rs index c1a90c4..d17a87f 100644 --- a/src/castable_factory/threadsafe.rs +++ b/src/castable_factory/threadsafe.rs @@ -1,5 +1,6 @@ use std::any::type_name; use std::fmt::Debug; +use std::marker::Tuple; use crate::interfaces::any_factory::{AnyFactory, AnyThreadsafeFactory}; use crate::interfaces::factory::IThreadsafeFactory; @@ -7,7 +8,7 @@ use crate::ptr::TransientPtr; pub struct ThreadsafeCastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { func: &'static (dyn Fn> + Send + Sync), @@ -15,7 +16,7 @@ where impl ThreadsafeCastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { pub fn new( @@ -31,14 +32,14 @@ where impl IThreadsafeFactory for ThreadsafeCastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { } impl Fn for ThreadsafeCastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { extern "rust-call" fn call(&self, args: Args) -> Self::Output @@ -50,7 +51,7 @@ where impl FnMut for ThreadsafeCastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output @@ -62,7 +63,7 @@ where impl FnOnce for ThreadsafeCastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { type Output = TransientPtr; @@ -76,7 +77,7 @@ where impl AnyFactory for ThreadsafeCastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { } @@ -84,14 +85,14 @@ where impl AnyThreadsafeFactory for ThreadsafeCastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { } impl Debug for ThreadsafeCastableFactory where - Args: 'static, + Args: Tuple + 'static, ReturnInterface: 'static + ?Sized, { #[cfg(not(tarpaulin_include))] diff --git a/src/di_container/asynchronous/binding/builder.rs b/src/di_container/asynchronous/binding/builder.rs index 3d03562..3ea8a35 100644 --- a/src/di_container/asynchronous/binding/builder.rs +++ b/src/di_container/asynchronous/binding/builder.rs @@ -185,7 +185,7 @@ where AsyncBindingBuilderError, > where - Args: 'static, + Args: std::marker::Tuple + 'static, Return: 'static + ?Sized, Interface: Fn + Send + Sync, FactoryFunc: @@ -278,7 +278,7 @@ where AsyncBindingBuilderError, > where - Args: 'static, + Args: std::marker::Tuple + 'static, Return: 'static + ?Sized, Interface: Fn> + Send + Sync, diff --git a/src/di_container/blocking/binding/builder.rs b/src/di_container/blocking/binding/builder.rs index 7aa1755..29422b6 100644 --- a/src/di_container/blocking/binding/builder.rs +++ b/src/di_container/blocking/binding/builder.rs @@ -198,7 +198,7 @@ where BindingBuilderError, > where - Args: 'static, + Args: std::marker::Tuple + 'static, Return: 'static + ?Sized, Interface: Fn>, Func: Fn<(std::rc::Rc,), Output = Box>, diff --git a/src/interfaces/factory.rs b/src/interfaces/factory.rs index 58cf56f..c67abd6 100644 --- a/src/interfaces/factory.rs +++ b/src/interfaces/factory.rs @@ -1,3 +1,5 @@ +use std::marker::Tuple; + use crate::libs::intertrait::CastFrom; use crate::ptr::TransientPtr; @@ -5,6 +7,7 @@ use crate::ptr::TransientPtr; pub trait IFactory: Fn> + CastFrom where + Args: Tuple, ReturnInterface: 'static + ?Sized, { } @@ -14,6 +17,7 @@ where pub trait IThreadsafeFactory: Fn> + crate::libs::intertrait::CastFromSync where + Args: Tuple, ReturnInterface: 'static + ?Sized, { } diff --git a/src/lib.rs b/src/lib.rs index a117ccc..3bddf1b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![cfg_attr(feature = "factory", feature(unboxed_closures, fn_traits))] +#![cfg_attr(feature = "factory", feature(unboxed_closures, fn_traits, tuple_trait))] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![deny(clippy::all)] #![deny(clippy::pedantic)] -- cgit v1.2.3-18-g5258