From 437fbda03607051e33335470672a37da34b404dc Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Wed, 20 Sep 2023 10:24:43 -0500 Subject: [PATCH] Implement LifetimeFree for tuples (#17) Implement `LifetimeFree` for tuples with up to 10 elements, whose elements also implement `LifetimeFree`. --- src/lifetime_free.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lifetime_free.rs b/src/lifetime_free.rs index 36fc330..49ffe59 100644 --- a/src/lifetime_free.rs +++ b/src/lifetime_free.rs @@ -83,6 +83,27 @@ unsafe impl LifetimeFree for core::num::Wrapping {} unsafe impl LifetimeFree for core::cell::Cell {} unsafe impl LifetimeFree for core::cell::RefCell {} +macro_rules! tuple_impls { + ($( $( $name:ident )+, )+) => { + $( + unsafe impl<$($name: LifetimeFree),+> LifetimeFree for ($($name,)+) {} + )+ + }; +} + +tuple_impls! { + T0, + T0 T1, + T0 T1 T2, + T0 T1 T2 T3, + T0 T1 T2 T3 T4, + T0 T1 T2 T3 T4 T5, + T0 T1 T2 T3 T4 T5 T6, + T0 T1 T2 T3 T4 T5 T6 T7, + T0 T1 T2 T3 T4 T5 T6 T7 T8, + T0 T1 T2 T3 T4 T5 T6 T7 T8 T9, +} + #[cfg(feature = "std")] mod std_impls { use super::LifetimeFree;