shared_is_same_after_clone
Some checks failed
buildbot/cargo fmt (1.72) Build done.
buildbot/cargo clippy (1.65) Build done.
buildbot/cargo clippy (1.72) Build done.
buildbot/cargo doc (1.72) Build done.
buildbot/cargo test (1.65) Build done.

This commit is contained in:
AF 2023-10-15 17:39:28 +00:00
parent 807ff5e589
commit 7ed5e9f255
3 changed files with 19 additions and 1 deletions

View File

@ -22,7 +22,7 @@ pub trait Effect: Send {
}
/// Value and related metadata.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Clone)]
pub struct WithEffect<A, E> {
pub value: A,
pub effect: E,

View File

@ -127,5 +127,8 @@ pub fn shared_follows_laws<'a, T: SharedFunctor<'a> + FunctorTestSuite<'a>>() ->
T::sample(|pa| {
res += shared_is_same_as_original::<T, _>(move || pa(2));
});
T::sample(|pa| {
res += shared_is_same_after_clone::<T, _>(move || pa(2));
});
res
}

View File

@ -463,3 +463,18 @@ pub fn shared_is_same_as_original<
fa0(),
)
}
pub fn shared_is_same_after_clone<
'a,
T: SharedFunctor<'a> + Eqr<'a>,
A: 'a + Send + Sync + Clone + Debug + PartialEq,
>(
fa0: impl 'a + Fn() -> T::F<A>,
) -> R {
let sa = T::share(fa0());
T::eqr(
"shared same as original",
T::unshare(sa.clone()),
T::unshare(sa),
)
}