Diffstat (limited to 'tests/builder_struct.rs')
-rw-r--r--tests/builder_struct.rs39
1 files changed, 34 insertions, 5 deletions
diff --git a/tests/builder_struct.rs b/tests/builder_struct.rs
index af56538..8f85854 100644
--- a/tests/builder_struct.rs
+++ b/tests/builder_struct.rs
@@ -17,10 +17,7 @@ use treaty::{
Build, Builder, DefaultMode, Flow, Walk, Walker,
};
-use crate::common::{
- protocol::sequence::MockSequenceScope,
- walker::MockWalker,
-};
+use crate::common::{protocol::sequence::MockSequenceScope, walker::MockWalker};
mod common;
@@ -75,7 +72,7 @@ struct Fields<'ctx, M, E: Effect> {
b: <bool as Build<'ctx, M, E>>::Builder,
}
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Debug)]
enum FieldMarker {
A,
B,
@@ -283,3 +280,35 @@ fn from_basic_map_like() {
// The struct is built as the mock walker above makes it.
assert_eq!(builder.build().value().unwrap(), X { a: false, b: true });
}
+
+pub mod demo {
+ use crate::Walk;
+ use macro_rules_attribute::derive;
+ use treaty::{
+ effect::{Blocking, ReadyValue as _},
+ transform, Build, DefaultMode,
+ };
+
+ #[derive(Build!, Walk!, Debug)]
+ pub struct X {
+ pub a: bool,
+ pub b: bool,
+ }
+
+ #[derive(Build!, Walk!, Debug)]
+ pub struct Y {
+ pub b: bool,
+ pub a: bool,
+ }
+
+ #[no_mangle]
+ pub fn ident(x: X) -> Y {
+ let other = transform::<<Y as crate::Build<'_, DefaultMode, _>>::Builder, _, Blocking>(
+ ((), ()),
+ Walk::<DefaultMode, _>::into_walker(&x),
+ )
+ .value();
+
+ other.0.unwrap()
+ }
+}