Diffstat (limited to 'tests/builder_struct.rs')
| -rw-r--r-- | tests/builder_struct.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/builder_struct.rs b/tests/builder_struct.rs index b758379..f8eb0d6 100644 --- a/tests/builder_struct.rs +++ b/tests/builder_struct.rs @@ -1,7 +1,7 @@ +use effectful::is_send_sync; use macro_rules_attribute::derive; use treaty::{ any::{OwnedStatic, TempBorrowedStatic}, - effect::blocking::Blocking, protocol::{ visitor::{tags, visit_sequence, visit_tag, TagConst, VisitResult}, AsVisitor as _, @@ -13,6 +13,7 @@ use treaty::{ use crate::common::{ protocol::{sequence::MockSequenceScope, value::ValueVisitorExt as _}, walker::MockWalker, + Blocking, }; mod common; @@ -23,6 +24,8 @@ struct X { b: bool, } +is_send_sync!(X); + #[test] fn a_struct_builder_can_build_from_a_sequence_of_field_values() { let mut scope; @@ -55,12 +58,12 @@ fn a_struct_builder_can_build_from_a_sequence_of_field_values() { // Visit the sequence of field values. // The struct visitor should report as done. assert!(matches!( - visit_sequence(builder.as_visitor(), &mut scope).value(), + visit_sequence(builder.as_visitor(), &mut scope).into_value(), VisitResult::Control(Flow::Done) )); // The builder should be able to build a instance of the struct. - assert_eq!(builder.build().value().unwrap(), X { a: true, b: false }); + assert_eq!(builder.build().into_value().unwrap(), X { a: true, b: false }); } #[test] @@ -74,7 +77,7 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() { scope.expect_next().once().returning(|mut visitor| { let mut walker; { - walker = MockWalker::<(), ()>::new(); + walker = MockWalker::<(), (), Blocking>::new(); // We need to give the b field name in the key tag. walker.expect_walk().once().returning(|mut visitor| { @@ -86,7 +89,7 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() { // Tag the value with a key as the field name. assert_eq!( - visit_tag::<tags::Key, Blocking, _>(TagConst, visitor.cast(), walker).value(), + visit_tag::<tags::Key, Blocking, _>(TagConst, visitor.cast(), walker).into_value(), Ok(VisitResult::Control(Flow::Continue)), ); @@ -101,7 +104,7 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() { scope.expect_next().once().returning(|mut visitor| { let mut walker; { - walker = MockWalker::<(), ()>::new(); + walker = MockWalker::<(), (), Blocking>::new(); // Here we do field a. walker.expect_walk().once().returning(|mut visitor| { @@ -113,7 +116,7 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() { // Tag the value with a key. assert_eq!( - visit_tag::<tags::Key, Blocking, _>(TagConst, visitor.cast(), walker).value(), + visit_tag::<tags::Key, Blocking, _>(TagConst, visitor.cast(), walker).into_value(), Ok(VisitResult::Control(Flow::Continue)), ); @@ -134,16 +137,16 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() { // This tag notifies the struct builder to expect the sequence as a map. assert_eq!( visit_tag::<tags::Map, Blocking, _>(TagConst, builder.as_visitor(), NoopWalker::new()) - .value(), + .into_value(), Ok(VisitResult::Control(Flow::Continue)) ); // Visit the sequence of fields. assert_eq!( - visit_sequence(builder.as_visitor(), &mut scope).value(), + visit_sequence(builder.as_visitor(), &mut scope).into_value(), VisitResult::Control(Flow::Done) ); // The struct is built as the mock walker above makes it. - assert_eq!(builder.build().value().unwrap(), X { a: false, b: true }); + assert_eq!(builder.build().into_value().unwrap(), X { a: false, b: true }); } |