Diffstat (limited to 'src/any/static_wrapper.rs')
| -rw-r--r-- | src/any/static_wrapper.rs | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/src/any/static_wrapper.rs b/src/any/static_wrapper.rs index f27b34e..efc6839 100644 --- a/src/any/static_wrapper.rs +++ b/src/any/static_wrapper.rs @@ -13,14 +13,16 @@ pub struct OwnedStatic<T: ?Sized>(pub T); forward_send_sync!({T: (?Sized)} {} OwnedStatic<T>); -impl<'a, 'ctx, E: EnvConfig, T> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for OwnedStatic<T> +impl<'a, 'ctx, E: EnvConfig, T> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> + for OwnedStatic<T> where T: DynBind<E> + 'static, { type T = OwnedStatic<T>; } -impl<'a, 'ctx, E: EnvConfig, T> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> for OwnedStatic<T> +impl<'a, 'ctx, E: EnvConfig, T> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> + for OwnedStatic<T> where T: DynBind<E> + 'static, { @@ -36,7 +38,8 @@ forward_send_sync!({} {T: (?Sized + 'ctx)} {{'ctx}} BorrowedStatic<'ctx, T>); pub struct BorrowedStaticHrt<T: ?Sized>(Marker<T>); -impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for BorrowedStaticHrt<T> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> + for BorrowedStaticHrt<T> where T: DynBind<E> + IsSync<E::NeedSend> + 'static, { @@ -135,7 +138,8 @@ pub struct BoxedStatic<T: ?Sized>(pub Box<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> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> + for BoxedStatic<T> where T: DynBind<E> + 'static, { @@ -143,7 +147,8 @@ where } #[cfg(feature = "alloc")] -impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> for BoxedStatic<T> +impl<'a, 'ctx, E: EnvConfig, T: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> + for BoxedStatic<T> where T: DynBind<E> + 'static, { @@ -152,13 +157,17 @@ where #[cfg(test)] mod test { + use effectful::{block_on::Spin, bound::No, environment::Cfg, blocking::Blocking as Block}; + use super::*; + type Blocking = Block<Cfg<Spin, No, No>>; + #[test] fn owned_static_has_type_name() { - let a = TypeNameId::of_value(&OwnedStatic(42_i32)); - let b = TypeNameId::of_value(&OwnedStatic(123_i32)); - let c = TypeNameId::of_value(&OwnedStatic(true)); + let a = TypeNameId::of_value::<_, Blocking>(&OwnedStatic(42_i32)); + let b = TypeNameId::of_value::<_, Blocking>(&OwnedStatic(123_i32)); + let c = TypeNameId::of_value::<_, Blocking>(&OwnedStatic(true)); assert_eq!(a, b); assert_ne!(a, c); @@ -167,9 +176,9 @@ mod test { #[test] fn borrowed_static_has_type_name() { - let a = TypeNameId::of_value(&BorrowedStatic(&42_i32)); - let b = TypeNameId::of_value(&BorrowedStatic(&123_i32)); - let c = TypeNameId::of_value(&BorrowedStatic(&true)); + let a = TypeNameId::of_value::<_, Blocking>(&BorrowedStatic(&42_i32)); + let b = TypeNameId::of_value::<_, Blocking>(&BorrowedStatic(&123_i32)); + let c = TypeNameId::of_value::<_, Blocking>(&BorrowedStatic(&true)); assert_eq!(a, b); assert_ne!(a, c); @@ -178,9 +187,9 @@ mod test { #[test] fn temp_borrowed_static_has_type_name() { - let a = TypeNameId::of_value(&TempBorrowedStatic(&42_i32)); - let b = TypeNameId::of_value(&TempBorrowedStatic(&123_i32)); - let c = TypeNameId::of_value(&TempBorrowedStatic(&true)); + let a = TypeNameId::of_value::<_, Blocking>(&TempBorrowedStatic(&42_i32)); + let b = TypeNameId::of_value::<_, Blocking>(&TempBorrowedStatic(&123_i32)); + let c = TypeNameId::of_value::<_, Blocking>(&TempBorrowedStatic(&true)); assert_eq!(a, b); assert_ne!(a, c); @@ -193,9 +202,9 @@ mod test { let mut b = 123_i32; let mut c = true; - let a = TypeNameId::of_value(&BorrowedMutStatic(&mut a)); - let b = TypeNameId::of_value(&BorrowedMutStatic(&mut b)); - let c = TypeNameId::of_value(&BorrowedMutStatic(&mut c)); + let a = TypeNameId::of_value::<_, Blocking>(&BorrowedMutStatic(&mut a)); + let b = TypeNameId::of_value::<_, Blocking>(&BorrowedMutStatic(&mut b)); + let c = TypeNameId::of_value::<_, Blocking>(&BorrowedMutStatic(&mut c)); assert_eq!(a, b); assert_ne!(a, c); @@ -208,9 +217,9 @@ mod test { let mut b = 123_i32; let mut c = true; - let a = TypeNameId::of_value(&TempBorrowedMutStatic(&mut a)); - let b = TypeNameId::of_value(&TempBorrowedMutStatic(&mut b)); - let c = TypeNameId::of_value(&TempBorrowedMutStatic(&mut c)); + let a = TypeNameId::of_value::<_, Blocking>(&TempBorrowedMutStatic(&mut a)); + let b = TypeNameId::of_value::<_, Blocking>(&TempBorrowedMutStatic(&mut b)); + let c = TypeNameId::of_value::<_, Blocking>(&TempBorrowedMutStatic(&mut c)); assert_eq!(a, b); assert_ne!(a, c); @@ -220,9 +229,9 @@ mod test { #[test] #[cfg(feature = "alloc")] fn boxed_static_has_type_name() { - let a = TypeNameId::of_value(&BoxedStatic(Box::new(42_i32))); - let b = TypeNameId::of_value(&BoxedStatic(Box::new(123_i32))); - let c = TypeNameId::of_value(&BoxedStatic(Box::new(true))); + let a = TypeNameId::of_value::<_, Blocking>(&BoxedStatic(Box::new(42_i32))); + let b = TypeNameId::of_value::<_, Blocking>(&BoxedStatic(Box::new(123_i32))); + let c = TypeNameId::of_value::<_, Blocking>(&BoxedStatic(Box::new(true))); assert_eq!(a, b); assert_ne!(a, c); |