Diffstat (limited to 'src/any/static_wrapper.rs')
| -rw-r--r-- | src/any/static_wrapper.rs | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/src/any/static_wrapper.rs b/src/any/static_wrapper.rs index 035b5da..f27b34e 100644 --- a/src/any/static_wrapper.rs +++ b/src/any/static_wrapper.rs @@ -1,5 +1,7 @@ //! Wrapper types that impl [`TypeName`] when their generic type `T` is `'static`. +use effectful::forward_send_sync; + use crate::hkt::Marker; use super::*; @@ -9,16 +11,18 @@ use super::*; #[repr(transparent)] pub struct OwnedStatic<T: ?Sized>(pub T); -impl<'a, 'ctx, T> TypeName::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> for OwnedStatic<T> +forward_send_sync!({T: (?Sized)} {} OwnedStatic<T>); + +impl<'a, 'ctx, E: EnvConfig, T> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for OwnedStatic<T> where - T: 'static + Send + Sync, + T: DynBind<E> + 'static, { type T = OwnedStatic<T>; } -impl<'a, 'ctx, T> TypeName::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> for OwnedStatic<T> +impl<'a, 'ctx, E: EnvConfig, T> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> for OwnedStatic<T> where - T: 'static + Send + Sync, + T: DynBind<E> + 'static, { type Higher = OwnedStatic<T>; } @@ -28,19 +32,21 @@ where #[repr(transparent)] pub struct BorrowedStatic<'ctx, T: ?Sized>(pub &'ctx T); +forward_send_sync!({} {T: (?Sized + 'ctx)} {{'ctx}} BorrowedStatic<'ctx, T>); + pub struct BorrowedStaticHrt<T: ?Sized>(Marker<T>); -impl<'a, 'ctx, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> for BorrowedStaticHrt<T> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for BorrowedStaticHrt<T> where - T: 'static + Send + Sync, + T: DynBind<E> + IsSync<E::NeedSend> + 'static, { type T = BorrowedStatic<'ctx, T>; } -impl<'a, 'ctx, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> for BorrowedStatic<'ctx, T> where - T: 'static + Send + Sync, + T: DynBind<E> + IsSync<E::NeedSend> + 'static, { type Higher = BorrowedStaticHrt<T>; } @@ -50,20 +56,22 @@ where #[repr(transparent)] pub struct TempBorrowedStatic<'a, T: ?Sized>(pub &'a T); +forward_send_sync!({} {T: (?Sized + 'ctx)} {{'ctx}} TempBorrowedStatic<'ctx, T>); + pub struct TempBorrowedStaticHrt<T: ?Sized>(Marker<T>); -impl<'a, 'ctx, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for TempBorrowedStaticHrt<T> where - T: 'static + Send + Sync, + T: DynBind<E> + IsSync<E::NeedSend> + 'static, { type T = TempBorrowedStatic<'a, T>; } -impl<'a, 'ctx, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> for TempBorrowedStatic<'a, T> where - T: 'static + Send + Sync, + T: DynBind<E> + IsSync<E::NeedSend> + 'static, { type Higher = TempBorrowedStaticHrt<T>; } @@ -73,20 +81,22 @@ where #[repr(transparent)] pub struct BorrowedMutStatic<'ctx, T: ?Sized>(pub &'ctx mut T); +forward_send_sync!({T: (?Sized + 'ctx)} {} {{'ctx}} BorrowedMutStatic<'ctx, T>); + pub struct BorrowedMutStaticHrt<T: ?Sized>(Marker<T>); -impl<'a, 'ctx, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for BorrowedMutStaticHrt<T> where - T: 'static + Send + Sync, + T: DynBind<E> + 'static, { type T = BorrowedMutStatic<'ctx, T>; } -impl<'a, 'ctx, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> for BorrowedMutStatic<'ctx, T> where - T: 'static + Send + Sync, + T: DynBind<E> + 'static, { type Higher = BorrowedMutStaticHrt<T>; } @@ -96,20 +106,22 @@ where #[repr(transparent)] pub struct TempBorrowedMutStatic<'a, T: ?Sized>(pub &'a mut T); +forward_send_sync!({T: (?Sized + 'ctx)} {} {{'ctx}} TempBorrowedMutStatic<'ctx, T>); + pub struct TempBorrowedMutStaticHrt<T: ?Sized>(Marker<T>); -impl<'a, 'ctx, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for TempBorrowedMutStaticHrt<T> where - T: 'static + Send + Sync, + T: DynBind<E> + 'static, { type T = TempBorrowedMutStatic<'a, T>; } -impl<'a, 'ctx, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> for TempBorrowedMutStatic<'a, T> where - T: 'static + Send + Sync, + T: DynBind<E> + 'static, { type Higher = TempBorrowedMutStaticHrt<T>; } @@ -120,17 +132,20 @@ where pub struct BoxedStatic<T: ?Sized>(pub Box<T>); #[cfg(feature = "alloc")] -impl<'a, 'ctx, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> for BoxedStatic<T> +forward_send_sync!({T: (?Sized)} {} BoxedStatic<T>); + +#[cfg(feature = "alloc")] +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for BoxedStatic<T> where - T: 'static + Send + Sync, + T: DynBind<E> + 'static, { type T = BoxedStatic<T>; } #[cfg(feature = "alloc")] -impl<'a, 'ctx, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> for BoxedStatic<T> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> for BoxedStatic<T> where - T: 'static + Send + Sync, + T: DynBind<E> + 'static, { type Higher = BoxedStatic<T>; } |