Diffstat (limited to 'tests/demo.rs')
-rw-r--r--tests/demo.rs32
1 files changed, 19 insertions, 13 deletions
diff --git a/tests/demo.rs b/tests/demo.rs
index 0f0e190..6db1559 100644
--- a/tests/demo.rs
+++ b/tests/demo.rs
@@ -6,7 +6,7 @@ use treaty::{
into_walker,
protocol::{
visitor::{Sequence, SequenceScope, Value},
- ControlFlowFor, Ready, SyncEffect, Visitor,
+ ControlFlowFor, SyncEffect, Visitor,
},
Builder, Walk, Walker,
};
@@ -19,7 +19,8 @@ fn demo() {
Data::Bool(false),
]);
- // dbg!(array_to_array([true, false, true]));
+ dbg!(array_to_array2([true, false]));
+ dbg!(array_to_array([true, true]));
let s = build_with::<array::Builder<'_, JsonLike, 3>, _>(into_walker(&a)).unwrap();
dbg!(s);
@@ -30,9 +31,14 @@ fn demo() {
// assert_eq!(s, "[true,[false,true,],false,]");
}
-#[no_mangle]
-pub fn array_to_array(x: [bool; 1]) -> [bool; 1] {
- unsafe { build(into_walker(x)).unwrap_unchecked() }
+#[inline(never)]
+pub fn array_to_array(x: [bool; 2]) -> [bool; 2] {
+ build(into_walker(x)).unwrap()
+}
+
+#[inline(never)]
+pub fn array_to_array2(x: [bool; 2]) -> [bool; 2] {
+ array_to_array(x)
}
#[derive(Debug)]
@@ -69,7 +75,7 @@ const _: () = {
Data::Bool(value) => walk_bool(*value, visitor),
Data::Sequence(value) => walk_vec(value, visitor),
}
- Ready::new(core::ops::ControlFlow::Continue(()))
+ core::ops::ControlFlow::Continue(())
}
}
};
@@ -92,13 +98,13 @@ fn walk_vec<'a, 'ctx>(value: &'ctx [Data], visitor: &'a mut Visitor<'a, 'ctx>) {
if let Some(value) = self.0.pop_front() {
into_walker(value).walk(visitor);
- Ready::new(ControlFlow::Continue(
+ ControlFlow::Continue(
treaty::protocol::visitor::Status::Continue,
- ))
+ )
} else {
- Ready::new(ControlFlow::Continue(
+ ControlFlow::Continue(
treaty::protocol::visitor::Status::Done,
- ))
+ )
}
}
}
@@ -138,7 +144,7 @@ any_trait! {
impl Value<'_, OwnedStatic<bool>> for JsonLike {
fn visit(&mut self, value: OwnedStatic<bool>) -> ControlFlowFor<'_> {
self.0.push_str(&format!("{}", value.0));
- Ready::new(ControlFlow::Continue(()))
+ ControlFlow::Continue(())
}
}
@@ -149,11 +155,11 @@ impl<'ctx> Sequence<'ctx> for JsonLike {
) -> ControlFlowFor<'a, SyncEffect> {
self.0.push_str("[");
while let ControlFlow::Continue(treaty::protocol::visitor::Status::Continue) =
- scope.next(self).into_inner()
+ scope.next(self)
{
self.0.push_str(",");
}
self.0.push_str("]");
- Ready::new(ControlFlow::Continue(()))
+ ControlFlow::Continue(())
}
}