Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 97 |
1 files changed, 53 insertions, 44 deletions
@@ -85,6 +85,15 @@ pub enum Flow { Done, } +impl ConvertShort<Flow> for Option<effectful::Never> { + fn convert_short(short: Self) -> Flow { + match short { + None => Flow::Done, + Some(_) => unreachable!(), + } + } +} + impl Flow { pub fn to_status(self) -> Status { match self { @@ -124,7 +133,7 @@ macro_rules! Walk { ),* $(,)?} } => { const _: () = { - impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::Walk<'ctx, M, E> for &'ctx $name + impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::Walk<'ctx, M, E> for &'ctx $name where $name: effectful::bound::IsSync<E::NeedSend> + effectful::environment::DynBind<E> { @@ -159,7 +168,7 @@ macro_rules! Walk { } } - impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::walkers::core::r#struct::StructTypeInfo<'ctx, M, E> for Info + impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::walkers::core::r#struct::StructTypeInfo<'ctx, M, E> for Info where $name: effectful::bound::IsSync<E::NeedSend> + effectful::environment::DynBind<E> { @@ -257,45 +266,45 @@ macro_rules! Walk { // } // } -pub mod demo { - use crate::{Build, BuildExt as _}; - use crate::{Walk, WalkExt as _}; - use macro_rules_attribute::derive; - - #[derive(Walk!)] - pub struct X { - pub a: bool, - pub b: bool, - } - - #[derive(Build!, PartialEq, Debug)] - pub struct Y { - pub b: bool, - pub a: bool, - } - - #[inline(never)] - pub fn ident(x: X) -> Y { - Y::build(x.as_walker()).unwrap() - // x.walk(Y::new_builder()).unwrap() - } - - #[test] - fn demo() { - assert_eq!(ident(X { a: true, b: false }), Y { a: true, b: false }); - - crate::effect::blocking::Spin::block_on(async { - let x = X { a: false, b: true }; - - let y = Y::build_async(x.as_async_walker().await).await.unwrap(); - - assert_eq!(y, Y { a: false, b: true }); - }); - - let x = X { a: false, b: true }; - - let y = Y::build(x.as_walker()).unwrap(); - - assert_eq!(y, Y { a: false, b: true }); - } -} +// pub mod demo { +// use crate::{Build, BuildExt as _}; +// use crate::{Walk, WalkExt as _}; +// use macro_rules_attribute::derive; +// +// #[derive(Walk!)] +// pub struct X { +// pub a: bool, +// pub b: bool, +// } +// +// #[derive(Build!, PartialEq, Debug)] +// pub struct Y { +// pub b: bool, +// pub a: bool, +// } +// +// #[inline(never)] +// pub fn ident(x: X) -> Y { +// Y::build(x.as_walker()).unwrap() +// // x.walk(Y::new_builder()).unwrap() +// } +// +// #[test] +// fn demo() { +// assert_eq!(ident(X { a: true, b: false }), Y { a: true, b: false }); +// +// crate::effect::blocking::Spin::block_on(async { +// let x = X { a: false, b: true }; +// +// let y = Y::build_async(x.as_async_walker().await).await.unwrap(); +// +// assert_eq!(y, Y { a: false, b: true }); +// }); +// +// let x = X { a: false, b: true }; +// +// let y = Y::build(x.as_walker()).unwrap(); +// +// assert_eq!(y, Y { a: false, b: true }); +// } +// } |