Diffstat (limited to 'tests/common/protocol/sequence.rs')
| -rw-r--r-- | tests/common/protocol/sequence.rs | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/tests/common/protocol/sequence.rs b/tests/common/protocol/sequence.rs index 43e71db..c580f05 100644 --- a/tests/common/protocol/sequence.rs +++ b/tests/common/protocol/sequence.rs @@ -1,7 +1,11 @@ +use effectful::{ + bound::{Bool, IsSend, IsSync}, + effective::Effective, + environment::{Environment, NativeForm}, +}; use mockall::mock; use treaty::{ any::{any_trait, TypeName}, - effect::{Effect, Effective, ErasedEffective}, protocol::DynWalker, protocol::{ visitor::{ @@ -19,38 +23,44 @@ mock! { } } +unsafe impl<E: Environment, F: Bool> IsSend<F> for MockSequenceVisitor<E> {} +unsafe impl<E: Environment, F: Bool> IsSync<F> for MockSequenceVisitor<E> {} + any_trait! { - impl['ctx, E] MockSequenceVisitor<E> = [ + impl['ctx][E] MockSequenceVisitor<E> = [ SequenceProto<E> ] where - E: Effect, + E: Environment, } -impl<'ctx, E: Effect> Sequence<'ctx, E> for MockSequenceVisitor<E> { +impl<'ctx, E: Environment> Sequence<'ctx, E> for MockSequenceVisitor<E> { fn visit<'a: 'c, 'b: 'c, 'c>( &'a mut self, scope: DynSequenceScope<'b, 'ctx, E>, - ) -> ErasedEffective<'c, VisitResult, E> { - E::ready(self.visit(scope)) + ) -> NativeForm<'c, VisitResult, E> { + E::value(self.visit(scope)).cast() } } mock! { - pub SequenceScope<E> { + pub SequenceScope<E: Environment> { pub fn size_hint(&mut self) -> (usize, Option<usize>); - pub fn next<'a, 'b, 'ctx>(&'a mut self, visitor: DynVisitor<'b, 'ctx>) -> Flow; + pub fn next<'a, 'b, 'ctx>(&'a mut self, visitor: DynVisitor<'b, 'ctx, E>) -> Flow; } } -impl<'ctx, E: Effect> SequenceScope<'ctx, E> for MockSequenceScope<E> { - fn size_hint(&mut self) -> ErasedEffective<'_, (usize, Option<usize>), E> { - E::ready(self.size_hint()) +unsafe impl<E: Environment, F: Bool> IsSend<F> for MockSequenceScope<E> {} +unsafe impl<E: Environment, F: Bool> IsSync<F> for MockSequenceScope<E> {} + +impl<'ctx, E: Environment> SequenceScope<'ctx, E> for MockSequenceScope<E> { + fn size_hint(&mut self) -> NativeForm<'_, (usize, Option<usize>), E> { + E::value(self.size_hint()).cast() } fn next<'a: 'c, 'b: 'c, 'c>( &'a mut self, - visitor: DynVisitor<'b, 'ctx>, - ) -> ErasedEffective<'c, Flow, E> { - E::ready(self.next(visitor)) + visitor: DynVisitor<'b, 'ctx, E>, + ) -> NativeForm<'c, Flow, E> { + E::value(self.next(visitor)).cast() } } |