-rw-r--r--src/any.rs3
-rw-r--r--src/any/indirect.rs8
-rw-r--r--src/any/static_wrapper.rs2
-rw-r--r--src/build/builders/core.rs3
-rw-r--r--src/build/builders/core/bool.rs8
-rw-r--r--src/build/builders/core/enum.rs6
-rw-r--r--src/build/builders/core/struct.rs32
-rw-r--r--src/build/builders/core/value.rs9
-rw-r--r--src/macros/build.rs28
-rw-r--r--src/protocol/visitor.rs3
-rw-r--r--src/protocol/visitor/recoverable.rs3
-rw-r--r--src/protocol/visitor/request_hint.rs7
-rw-r--r--src/protocol/visitor/sequence.rs3
-rw-r--r--src/protocol/visitor/value.rs7
-rw-r--r--src/protocol/walker/hint.rs3
-rw-r--r--src/transform.rs2
-rw-r--r--src/walk/walkers/core/bool.rs8
-rw-r--r--src/walk/walkers/core/int.rs2
-rw-r--r--src/walk/walkers/core/key_value.rs3
-rw-r--r--src/walk/walkers/core/noop.rs3
-rw-r--r--src/walk/walkers/core/struct.rs7
-rw-r--r--src/walk/walkers/core/tag.rs3
-rw-r--r--src/walk/walkers/core/value.rs20
-rw-r--r--src/walk/walkers/serde/deserializer.rs92
-rw-r--r--tests/builder_enum.rs5
-rw-r--r--tests/common/builder.rs18
-rw-r--r--tests/common/protocol/request_hint.rs3
-rw-r--r--tests/common/protocol/sequence.rs3
-rw-r--r--tests/common/protocol/tag.rs4
-rw-r--r--tests/common/protocol/value.rs7
-rw-r--r--tests/common/walker.rs12
-rw-r--r--tests/protocol_visitor_recoverable.rs10
-rw-r--r--tests/protocol_visitor_request_hint.rs5
-rw-r--r--tests/protocol_visitor_sequence.rs5
-rw-r--r--tests/protocol_visitor_tag.rs10
-rw-r--r--tests/protocol_visitor_value.rs11
-rw-r--r--tests/serde_deserializer.rs6
-rw-r--r--tests/walker_struct.rs124
38 files changed, 284 insertions, 204 deletions
diff --git a/src/any.rs b/src/any.rs
index 00249bc..e3d53d4 100644
--- a/src/any.rs
+++ b/src/any.rs
@@ -11,7 +11,8 @@ use core::marker::PhantomData;
use effectful::{
bound::IsSync,
- environment::{DynBind, EnvConfig, Environment, InEnvironment}, SendSync,
+ environment::{DynBind, EnvConfig, Environment, InEnvironment},
+ SendSync,
};
pub use static_wrapper::*;
pub use type_name_id::*;
diff --git a/src/any/indirect.rs b/src/any/indirect.rs
index 2b4eccd..e1fb58a 100644
--- a/src/any/indirect.rs
+++ b/src/any/indirect.rs
@@ -97,7 +97,9 @@ pub(super) mod sealed {
fn into_raw<T: ?Sized + 'a>(value: Self::ForT<T>) -> MaybeUninit<[u8; INDIRECT_SIZE]> {
// SAFETY: A possibly fat borrow can be stores in a 2 usize wide maybe uninit array.
#[allow(unsafe_code)]
- unsafe { transmute::<&'a T, MaybeUninit<[u8; INDIRECT_SIZE]>>(value) }
+ unsafe {
+ transmute::<&'a T, MaybeUninit<[u8; INDIRECT_SIZE]>>(value)
+ }
}
#[allow(unsafe_code)]
@@ -111,7 +113,9 @@ pub(super) mod sealed {
fn into_raw<T: ?Sized + 'a>(value: Self::ForT<T>) -> MaybeUninit<[u8; INDIRECT_SIZE]> {
// SAFETY: A possibly fat borrow can be stores in a 2 usize wide maybe uninit array.
#[allow(unsafe_code)]
- unsafe { transmute::<&'a mut T, MaybeUninit<[u8; INDIRECT_SIZE]>>(value) }
+ unsafe {
+ transmute::<&'a mut T, MaybeUninit<[u8; INDIRECT_SIZE]>>(value)
+ }
}
#[allow(unsafe_code)]
diff --git a/src/any/static_wrapper.rs b/src/any/static_wrapper.rs
index 4497fbd..b846f81 100644
--- a/src/any/static_wrapper.rs
+++ b/src/any/static_wrapper.rs
@@ -149,7 +149,7 @@ where
#[cfg(test)]
mod test {
- use effectful::{block_on::Spin, bound::No, environment::Cfg, blocking::Blocking as Block};
+ use effectful::{block_on::Spin, blocking::Blocking as Block, bound::No, environment::Cfg};
use super::*;
diff --git a/src/build/builders/core.rs b/src/build/builders/core.rs
index a717b13..fa5da7d 100644
--- a/src/build/builders/core.rs
+++ b/src/build/builders/core.rs
@@ -1,7 +1,8 @@
use effectful::{
effective::Effective,
environment::{Environment, NativeForm},
- higher_ranked::Mut, SendSync,
+ higher_ranked::Mut,
+ SendSync,
};
use crate::{
diff --git a/src/build/builders/core/bool.rs b/src/build/builders/core/bool.rs
index 4f8f2f0..5001ba6 100644
--- a/src/build/builders/core/bool.rs
+++ b/src/build/builders/core/bool.rs
@@ -1,11 +1,13 @@
use super::value::{Cloneable, ValueBuilder};
-use effectful::environment::{Environment, DynBind};
+use crate::any::{
+ BorrowedMutStatic, BorrowedStatic, OwnedStatic, TempBorrowedMutStatic, TempBorrowedStatic,
+};
use effectful::bound::{Dynamic, IsSync};
-use crate::any::{OwnedStatic, BorrowedStatic, TempBorrowedStatic, BorrowedMutStatic, TempBorrowedMutStatic};
+use effectful::environment::{DynBind, Environment};
macro_rules! value_builder {
[$($ty:ty),*] => {
- $(impl<'ctx, M, E: Environment> crate::Build<'ctx, M, E> for $ty
+ $(impl<'ctx, M, E: Environment> crate::Build<'ctx, M, E> for $ty
where
Dynamic<Self>: DynBind<E>,
for<'a> Dynamic<&'a Self>: DynBind<E>,
diff --git a/src/build/builders/core/enum.rs b/src/build/builders/core/enum.rs
index 4294fff..7aff4cf 100644
--- a/src/build/builders/core/enum.rs
+++ b/src/build/builders/core/enum.rs
@@ -1,6 +1,6 @@
use core::fmt::{Debug, Display};
-use effectful::bound::{Bool, IsSend, IsSync, Dynamic};
+use effectful::bound::{Bool, Dynamic, IsSend, IsSync};
use effectful::effective::Effective;
use effectful::environment::{DynBind, Environment, NativeForm};
use effectful::higher_ranked::Mut;
@@ -82,7 +82,7 @@ pub trait EnumBuildInfo<'ctx, Mode, E: Environment> {
impl<'ctx, Info, Mode, E: Environment> BuilderTypes<E> for EnumBuilder<'ctx, Info, Mode, E>
where
Info: EnumBuildInfo<'ctx, Mode, E>,
- Dynamic<Info::T>: DynBind<E>
+ Dynamic<Info::T>: DynBind<E>,
{
type Seed = Info::Seed;
@@ -208,7 +208,7 @@ impl<'ctx, Info, Mode, E: Environment> Value<'ctx, Info::ValueT, E>
where
Info: EnumBuildInfo<'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
- for<'a> Dynamic<TypeName::T<'a, 'ctx, Info::ValueT, E>>: DynBind<E>
+ for<'a> Dynamic<TypeName::T<'a, 'ctx, Info::ValueT, E>>: DynBind<E>,
{
fn visit<'a>(
&'a mut self,
diff --git a/src/build/builders/core/struct.rs b/src/build/builders/core/struct.rs
index d08d06e..e9abc9c 100644
--- a/src/build/builders/core/struct.rs
+++ b/src/build/builders/core/struct.rs
@@ -1,12 +1,11 @@
use core::fmt::{Debug, Display};
use effectful::{
- bound::{IsSend, IsSync, Dynamic},
+ bound::{Dynamic, IsSend, IsSync},
effective::Effective,
environment::{DynBind, Environment, NativeForm},
higher_ranked::Mut,
- SendSync,
- tri,
+ tri, SendSync,
};
use crate::{
@@ -70,8 +69,7 @@ enum StructKind {
///
/// The `Mode` generic allows implementations to change depending on the mode the user gives.
/// It is not used by the trait directly.
-pub trait StructTypeInfo<'ctx, Mode: 'ctx, E: Environment>: 'static
-{
+pub trait StructTypeInfo<'ctx, Mode: 'ctx, E: Environment>: 'static {
/// A struct of builders for each field.
type Builders: DynBind<E>;
@@ -164,7 +162,7 @@ where
impl<'ctx, Info, Mode, E: Environment> BuilderTypes<E> for StructBuilder<'ctx, Info, Mode, E>
where
Info: StructTypeInfo<'ctx, Mode, E>,
- Dynamic<Info::T>: DynBind<E>
+ Dynamic<Info::T>: DynBind<E>,
{
type Seed = Info::Seed;
@@ -211,13 +209,13 @@ where
Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'ctx, Mode, E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
for<'a> Dynamic<&'a Info::T>: DynBind<E>,
for<'b, 'c> Dynamic<TypeName::T<'b, 'c, Info::ValueT, E>>: DynBind<E>,
- Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
+ Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
for<'b, 'c> Dynamic<&'b TypeName::T<'b, 'c, Info::ValueT, E>>: DynBind<E>,
- for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
+ for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
{
fn from_seed<'a>(seed: Self::Seed) -> NativeForm<'a, Self, E>
where
@@ -260,12 +258,12 @@ where
Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
- Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
+ Info: StructTypeInfo<'ctx, Mode, E>,
+ Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
for<'a> Dynamic<&'a Info::T>: DynBind<E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
for<'b, 'c> Dynamic<TypeName::T<'b, 'c, Info::ValueT, E>>: DynBind<E>,
- for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
+ for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
for<'b, 'c> Dynamic<&'b TypeName::T<'b, 'c, Info::ValueT, E>>: DynBind<E>,
{
fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'ctx, E>
@@ -308,7 +306,7 @@ where
for<'b, 'c> Dynamic<&'b TypeName::T<'b, 'c, Info::ValueT, E>>: DynBind<E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
- Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
+ Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
E: Environment,
{
#[inline(always)]
@@ -463,8 +461,8 @@ impl<'ctx, Info, Mode: 'ctx, E> Sequence<'ctx, E> for StructBuilder<'ctx, Info,
where
Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
- for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
- Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
+ for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
+ Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
E: Environment,
{
@@ -581,8 +579,8 @@ where
E: Environment,
I: StructTypeInfo<'ctx, M, E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
- Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
- for<'a> Dynamic<TempBorrowedStatic<'a, str>>: DynBind<E>,
+ Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
+ for<'a> Dynamic<TempBorrowedStatic<'a, str>>: DynBind<E>,
{
fn visit<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
diff --git a/src/build/builders/core/value.rs b/src/build/builders/core/value.rs
index 55a0e99..feec981 100644
--- a/src/build/builders/core/value.rs
+++ b/src/build/builders/core/value.rs
@@ -1,11 +1,12 @@
use core::fmt::Display;
use effectful::{
+ bound::Dynamic,
bound::IsSync,
effective::Effective,
environment::{DynBind, Environment, NativeForm},
- higher_ranked::Mut, SendSync,
- bound::Dynamic,
+ higher_ranked::Mut,
+ SendSync,
};
use crate::{
@@ -58,9 +59,9 @@ pub struct ValueBuilder<T, Clone, E> {
_marker: Marker<(E, Clone)>,
}
-impl<T, Clone, E: Environment> crate::BuilderTypes<E> for ValueBuilder<T, Clone, E>
+impl<T, Clone, E: Environment> crate::BuilderTypes<E> for ValueBuilder<T, Clone, E>
where
- Dynamic<T>: DynBind<E>
+ Dynamic<T>: DynBind<E>,
{
type Error = ValueError<T>;
diff --git a/src/macros/build.rs b/src/macros/build.rs
index 14e4443..4272bed 100644
--- a/src/macros/build.rs
+++ b/src/macros/build.rs
@@ -9,7 +9,7 @@ macro_rules! Build {
#[allow(non_upper_case_globals, non_snake_case, non_camel_case_types)]
const _: () = {
// add a module here to seal fields.
- impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::Build<'ctx, M, E> for $name
+ impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::Build<'ctx, M, E> for $name
where
effectful::bound::Dynamic<$name>: effectful::environment::DynBind<E>,
$($type: $crate::Build<'ctx, M, E>,)*
@@ -19,7 +19,7 @@ macro_rules! Build {
}
#[derive(SendSync)]
- $vis struct Builders<'ctx, M: 'ctx, E: effectful::environment::Environment>
+ $vis struct Builders<'ctx, M: 'ctx, E: effectful::environment::Environment>
where
$($type: $crate::Build<'ctx, M, E>),*
{
@@ -40,7 +40,7 @@ macro_rules! Build {
}
#[derive(SendSync)]
- $vis enum Error<'ctx, M: 'ctx, E: effectful::environment::Environment>
+ $vis enum Error<'ctx, M: 'ctx, E: effectful::environment::Environment>
where
$($type: $crate::Build<'ctx, M, E>),*
{
@@ -55,7 +55,7 @@ macro_rules! Build {
}
}
- impl<'ctx, M: 'ctx, E: effectful::environment::Environment> ::core::fmt::Debug for Error<'ctx, M, E>
+ impl<'ctx, M: 'ctx, E: effectful::environment::Environment> ::core::fmt::Debug for Error<'ctx, M, E>
where
$($type: $crate::Build<'ctx, M, E>),*
{
@@ -66,7 +66,7 @@ macro_rules! Build {
}
}
- impl<'ctx, M: 'ctx, E: effectful::environment::Environment> ::core::fmt::Display for Error<'ctx, M, E>
+ impl<'ctx, M: 'ctx, E: effectful::environment::Environment> ::core::fmt::Display for Error<'ctx, M, E>
where
$($type: $crate::Build<'ctx, M, E>),*
{
@@ -80,7 +80,7 @@ macro_rules! Build {
#[derive(SendSync)]
$vis struct __Info;
- impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::builders::core::r#struct::StructTypeInfo<'ctx, M, E> for __Info
+ impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::builders::core::r#struct::StructTypeInfo<'ctx, M, E> for __Info
where
effectful::bound::Dynamic<$name>: effectful::environment::DynBind<E>,
$($type: $crate::Build<'ctx, M, E>),*
@@ -168,7 +168,7 @@ macro_rules! Build {
#[allow(non_upper_case_globals, non_snake_case, non_camel_case_types)]
const _: () = {
// add a module here to seal fields.
- impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::Build<'ctx, M, E> for $name
+ impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::Build<'ctx, M, E> for $name
where
effectful::bound::Dynamic<$name>: effectful::environment::DynBind<E>,
$($value: $crate::Build<'ctx, M, E>,)*
@@ -182,7 +182,7 @@ macro_rules! Build {
$vis struct __Info;
#[derive(SendSync)]
- $vis enum __Builders<'ctx, M, E: effectful::environment::Environment>
+ $vis enum __Builders<'ctx, M, E: effectful::environment::Environment>
where
$($value: $crate::Build<'ctx, M, E>),*
{
@@ -211,7 +211,7 @@ macro_rules! Build {
}
#[derive(SendSync)]
- $vis struct __ErrorBuilder<'ctx, M, E: Environment>
+ $vis struct __ErrorBuilder<'ctx, M, E: Environment>
where
$($value: $crate::Build<'ctx, M, E>),*
{
@@ -219,7 +219,7 @@ macro_rules! Build {
}
#[derive(SendSync)]
- $vis enum __Error<'ctx, M, E: Environment>
+ $vis enum __Error<'ctx, M, E: Environment>
where
$($value: $crate::Build<'ctx, M, E>),*
{
@@ -229,7 +229,7 @@ macro_rules! Build {
$($variant(<<$value as $crate::Build<'ctx, M, E>>::Builder as BuilderTypes<E>>::Error)),*
}
- impl<'ctx, M, E: Environment> ::core::fmt::Display for __Error<'ctx, M, E>
+ impl<'ctx, M, E: Environment> ::core::fmt::Display for __Error<'ctx, M, E>
where
$($value: $crate::Build<'ctx, M, E>),*
{
@@ -247,7 +247,7 @@ macro_rules! Build {
}
}
- impl<'ctx, M, E: Environment> ::core::fmt::Debug for __Error<'ctx, M, E>
+ impl<'ctx, M, E: Environment> ::core::fmt::Debug for __Error<'ctx, M, E>
where
$($value: $crate::Build<'ctx, M, E>),*
{
@@ -265,7 +265,7 @@ macro_rules! Build {
}
}
- impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::builders::core::r#enum::EnumBuildInfo<'ctx, M, E> for __Info
+ impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::builders::core::r#enum::EnumBuildInfo<'ctx, M, E> for __Info
where
effectful::bound::Dynamic<$name>: effectful::environment::DynBind<E>,
$($value: $crate::Build<'ctx, M, E>,)*
@@ -336,7 +336,7 @@ macro_rules! Build {
E::value((scope, Err(__ErrorBuilder::<M, E> { A: None, B: None })))
$(.or_else_update((), |_, scope, result| {
let mut error = result.into_error();
-
+
<<$value as Build<M, E>>::Builder as Builder<_>>::from_seed(Default::default())
.map(scope, |scope, builder| (scope, builder))
.update((), |(), (scope, builder)| scope.new_walk(builder.as_visitor()).cast())
diff --git a/src/protocol/visitor.rs b/src/protocol/visitor.rs
index 087174e..321d16e 100644
--- a/src/protocol/visitor.rs
+++ b/src/protocol/visitor.rs
@@ -13,7 +13,8 @@ use effectful::{
effective::{Effective, SplitUpdateEffective},
environment::{DynBind, Environment, NativeForm},
for_lt,
- higher_ranked::Mut, SendSync,
+ higher_ranked::Mut,
+ SendSync,
};
pub use recoverable::*;
pub use request_hint::*;
diff --git a/src/protocol/visitor/recoverable.rs b/src/protocol/visitor/recoverable.rs
index ef20345..3939ab8 100644
--- a/src/protocol/visitor/recoverable.rs
+++ b/src/protocol/visitor/recoverable.rs
@@ -1,6 +1,7 @@
use effectful::{
effective::Effective,
- environment::{DynBind, EnvConfig, Environment, NativeForm}, SendSync,
+ environment::{DynBind, EnvConfig, Environment, NativeForm},
+ SendSync,
};
use crate::{
diff --git a/src/protocol/visitor/request_hint.rs b/src/protocol/visitor/request_hint.rs
index 183014f..ae2fcbf 100644
--- a/src/protocol/visitor/request_hint.rs
+++ b/src/protocol/visitor/request_hint.rs
@@ -2,7 +2,8 @@ use effectful::{
effective::Effective,
environment::{DynBind, Environment, NativeForm},
for_lt,
- higher_ranked::Mut, SendSync,
+ higher_ranked::Mut,
+ SendSync,
};
use crate::{
@@ -69,6 +70,8 @@ pub fn request_hint<'ctx: 'visitor + 'walker, 'visitor: 'e, 'walker: 'e, 'e, E:
E::value(VisitResult::Skipped(())).cast()
}
})
- .map((), |_, ((_, walker), result)| result.map_skipped(|_| walker))
+ .map((), |_, ((_, walker), result)| {
+ result.map_skipped(|_| walker)
+ })
.cast()
}
diff --git a/src/protocol/visitor/sequence.rs b/src/protocol/visitor/sequence.rs
index 3239faf..db3e3cc 100644
--- a/src/protocol/visitor/sequence.rs
+++ b/src/protocol/visitor/sequence.rs
@@ -1,6 +1,7 @@
use effectful::{
effective::Effective,
- environment::{DynBind, EnvConfig, Environment, NativeForm}, SendSync,
+ environment::{DynBind, EnvConfig, Environment, NativeForm},
+ SendSync,
};
use crate::{
diff --git a/src/protocol/visitor/value.rs b/src/protocol/visitor/value.rs
index 6efd1c5..9967f66 100644
--- a/src/protocol/visitor/value.rs
+++ b/src/protocol/visitor/value.rs
@@ -3,9 +3,10 @@
//! In some sense, this is the most basic protocol.
use effectful::{
- bound::{Bool, IsSend, IsSync, Dynamic},
+ bound::{Bool, Dynamic, IsSend, IsSync},
effective::Effective,
- environment::{DynBind, EnvConfig, Environment, NativeForm}, SendSync,
+ environment::{DynBind, EnvConfig, Environment, NativeForm},
+ SendSync,
};
use crate::{
@@ -116,7 +117,7 @@ pub fn visit_value<
) -> NativeForm<'e, VisitResult<Dynamic<T>>, E>
where
TypeName::HigherRanked<'e, 'ctx, T, E>: TypeName::MemberType<E>,
- Dynamic<T>: DynBind<E>
+ Dynamic<T>: DynBind<E>,
{
if let Some(object) = visitor
.0
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs
index 5d1dee9..cb8e60f 100644
--- a/src/protocol/walker/hint.rs
+++ b/src/protocol/walker/hint.rs
@@ -10,7 +10,8 @@ use effectful::{
bound::{IsSend, IsSync},
effective::Effective,
environment::{DynBind, EnvConfig, Environment, NativeForm},
- higher_ranked::Mut, SendSync,
+ higher_ranked::Mut,
+ SendSync,
};
use crate::{
diff --git a/src/transform.rs b/src/transform.rs
index 2bbc2c6..9d2ff38 100644
--- a/src/transform.rs
+++ b/src/transform.rs
@@ -1,7 +1,7 @@
use effectful::{
block_on::Spin,
blocking::Blocking,
- bound::{No, Yes, DynamicShim},
+ bound::{DynamicShim, No, Yes},
effective::Effective,
environment::{Cfg, Environment, NativeForm},
higher_ranked::Mut,
diff --git a/src/walk/walkers/core/bool.rs b/src/walk/walkers/core/bool.rs
index 5189ecc..af81c92 100644
--- a/src/walk/walkers/core/bool.rs
+++ b/src/walk/walkers/core/bool.rs
@@ -1,12 +1,14 @@
use effectful::{
- bound::Dynamic, effective::Effective, environment::{DynBind, Environment, NativeForm}
+ bound::Dynamic,
+ effective::Effective,
+ environment::{DynBind, Environment, NativeForm},
};
use crate::{any::OwnedStatic, Walk};
use super::value::ValueWalker;
-impl<'ctx, M, E: Environment> Walk<'ctx, M, E> for bool
+impl<'ctx, M, E: Environment> Walk<'ctx, M, E> for bool
where
Dynamic<bool>: DynBind<E>,
Dynamic<OwnedStatic<bool>>: DynBind<E>,
@@ -18,7 +20,7 @@ where
}
}
-impl<'ctx, M, E: Environment> Walk<'ctx, M, E> for &'ctx bool
+impl<'ctx, M, E: Environment> Walk<'ctx, M, E> for &'ctx bool
where
Dynamic<bool>: DynBind<E>,
Dynamic<OwnedStatic<bool>>: DynBind<E>,
diff --git a/src/walk/walkers/core/int.rs b/src/walk/walkers/core/int.rs
index 4d66dfc..1826803 100644
--- a/src/walk/walkers/core/int.rs
+++ b/src/walk/walkers/core/int.rs
@@ -1,7 +1,7 @@
+use effectful::bound::Dynamic;
use effectful::effective::Effective;
use effectful::environment::{DynBind, Environment, NativeForm};
use effectful::higher_ranked::Mut;
-use effectful::bound::Dynamic;
use effectful::SendSync;
use crate::{
diff --git a/src/walk/walkers/core/key_value.rs b/src/walk/walkers/core/key_value.rs
index 66e04ec..3ac3e31 100644
--- a/src/walk/walkers/core/key_value.rs
+++ b/src/walk/walkers/core/key_value.rs
@@ -1,6 +1,7 @@
use effectful::{
effective::Effective,
- environment::{Environment, NativeForm}, SendSync,
+ environment::{Environment, NativeForm},
+ SendSync,
};
use crate::{
diff --git a/src/walk/walkers/core/noop.rs b/src/walk/walkers/core/noop.rs
index 81425c3..bc6016f 100644
--- a/src/walk/walkers/core/noop.rs
+++ b/src/walk/walkers/core/noop.rs
@@ -1,6 +1,7 @@
use effectful::{
effective::Effective,
- environment::{Environment, NativeForm}, SendSync,
+ environment::{Environment, NativeForm},
+ SendSync,
};
use crate::{never::Never, protocol::DynVisitor};
diff --git a/src/walk/walkers/core/struct.rs b/src/walk/walkers/core/struct.rs
index 561a464..ac4a784 100644
--- a/src/walk/walkers/core/struct.rs
+++ b/src/walk/walkers/core/struct.rs
@@ -1,13 +1,14 @@
use core::any::TypeId;
use effectful::{
- bound::{IsSend, IsSync, Dynamic},
+ bound::{Dynamic, IsSend, IsSync},
effective::Effective,
- environment::{DynBind, Environment, NativeForm}, SendSync,
+ environment::{DynBind, Environment, NativeForm},
+ SendSync,
};
use crate::{
- any::{AnyTrait, BorrowedStatic, BorrowedStaticHrt, StaticType, OwnedStatic},
+ any::{AnyTrait, BorrowedStatic, BorrowedStaticHrt, OwnedStatic, StaticType},
any_trait,
hkt::Marker,
never::Never,
diff --git a/src/walk/walkers/core/tag.rs b/src/walk/walkers/core/tag.rs
index 40303ab..903be58 100644
--- a/src/walk/walkers/core/tag.rs
+++ b/src/walk/walkers/core/tag.rs
@@ -3,7 +3,8 @@ use core::marker::PhantomData;
use effectful::{
bound::IsSync,
effective::Effective,
- environment::{Environment, NativeForm}, SendSync,
+ environment::{Environment, NativeForm},
+ SendSync,
};
use crate::{
diff --git a/src/walk/walkers/core/value.rs b/src/walk/walkers/core/value.rs
index 3067a3d..ec5379d 100644
--- a/src/walk/walkers/core/value.rs
+++ b/src/walk/walkers/core/value.rs
@@ -1,12 +1,15 @@
use effectful::{
+ bound::Dynamic,
bound::IsSync,
effective::Effective,
- environment::{DynBind, Environment, NativeForm}, SendSync,
- bound::Dynamic
+ environment::{DynBind, Environment, NativeForm},
+ SendSync,
};
use crate::{
- any::{BorrowedStatic, OwnedStatic, TempBorrowedStatic, BorrowedStaticHrt, TempBorrowedStaticHrt},
+ any::{
+ BorrowedStatic, BorrowedStaticHrt, OwnedStatic, TempBorrowedStatic, TempBorrowedStaticHrt,
+ },
never::Never,
protocol::{
visitor::{visit_value, EffectiveVisitExt as _, VisitResult},
@@ -58,7 +61,7 @@ where
visitor: DynVisitor<'b, 'ctx, E>,
) -> NativeForm<'c, Result<Self::Output, Self::Error>, E> {
// Attempt to visit using the value protocol.
- visit_value::<OwnedStatic<T>, E>(visitor, OwnedStatic(self.0.0))
+ visit_value::<OwnedStatic<T>, E>(visitor, OwnedStatic(self.0 .0))
.map((), |_, _| Ok(()))
.cast()
}
@@ -78,12 +81,11 @@ impl<'ctx, T: ?Sized> BorrowWalker<'ctx, T> {
}
}
-impl<'ctx, T: ?Sized + 'static, E: Environment> crate::Walker<'ctx, E>
- for BorrowWalker<'ctx, T>
+impl<'ctx, T: ?Sized + 'static, E: Environment> crate::Walker<'ctx, E> for BorrowWalker<'ctx, T>
where
Dynamic<&'ctx T>: DynBind<E>,
Dynamic<BorrowedStatic<'ctx, T>>: DynBind<E>,
- for<'a> Dynamic<TempBorrowedStatic<'a, T>>: DynBind<E>
+ for<'a> Dynamic<TempBorrowedStatic<'a, T>>: DynBind<E>,
{
type Error = Never;
@@ -97,12 +99,12 @@ where
// Attempt to visit using the value protocol.
E::value((self, visitor))
.update((), |_, (this, visitor)| {
- visit_value::<_, E>(visitor.cast(), BorrowedStatic(this.0.0))
+ visit_value::<_, E>(visitor.cast(), BorrowedStatic(this.0 .0))
.map((), |_, x| VisitResult::unit_skipped(x))
.cast()
})
.if_skipped((), |_, (this, visitor)| {
- visit_value::<_, E>(visitor.cast(), TempBorrowedStatic(this.0.0))
+ visit_value::<_, E>(visitor.cast(), TempBorrowedStatic(this.0 .0))
.map((), |_, x| VisitResult::unit_skipped(x))
.cast()
})
diff --git a/src/walk/walkers/serde/deserializer.rs b/src/walk/walkers/serde/deserializer.rs
index 115ace1..8818102 100644
--- a/src/walk/walkers/serde/deserializer.rs
+++ b/src/walk/walkers/serde/deserializer.rs
@@ -1,4 +1,10 @@
-use effectful::{effective::NativeEffective, environment::{DynBind, Environment, NativeForm, EnvConfig}, SendSync, effective::Effective, bound::{No, Dynamic}};
+use effectful::{
+ bound::{Dynamic, No},
+ effective::Effective,
+ effective::NativeEffective,
+ environment::{DynBind, EnvConfig, Environment, NativeForm},
+ SendSync,
+};
use serde::{de::MapAccess, Deserializer};
use crate::{
@@ -7,7 +13,8 @@ use crate::{
hkt::Marker,
protocol::{
visitor::{
- request_hint, tags, visit_sequence, visit_value, EffectiveVisitExt as _, SequenceScope, TagConst, TagKnown, TagProto, ValueKnown, ValueProto, VisitResult
+ request_hint, tags, visit_sequence, visit_value, EffectiveVisitExt as _, SequenceScope,
+ TagConst, TagKnown, TagProto, ValueKnown, ValueProto, VisitResult,
},
walker::hint::{DynVisitorWith, Hint, HintMeta, HintProto, MetaHint, MetaKnown},
DynVisitor, DynWalker,
@@ -106,25 +113,25 @@ where
{
E::value((self, visitor))
.update((), |_, (this, visitor)| {
- // Serde deserializers usually prefer that a hint method is called rather than _any.
- // As such we need to ask the visitor for a hint first.
- request_hint::<E>(visitor.cast(), DynWalker(this))
- .map((), |_, x| VisitResult::unit_skipped(x))
+ // Serde deserializers usually prefer that a hint method is called rather than _any.
+ // As such we need to ask the visitor for a hint first.
+ request_hint::<E>(visitor.cast(), DynWalker(this))
+ .map((), |_, x| VisitResult::unit_skipped(x))
+ .cast()
+ })
+ .if_not_finished((), |_, (this, visitor)| {
+ this.call_deserialize(|deserializer| {
+ deserializer.deserialize_any(Visitor::<T, E>::new(visitor.cast(), "any"))
+ })
.cast()
- })
- .if_not_finished((), |_, (this, visitor)| {
- this.call_deserialize(|deserializer| {
- deserializer.deserialize_any(Visitor::<T, E>::new(visitor.cast(), "any"))
+ })
+ .map((), |_, ((this, _), _)| match this.inner {
+ Inner::Temp => todo!(),
+ Inner::Init(_) => todo!(),
+ Inner::Error(err) => Err(err),
+ Inner::Done => Ok(()),
})
.cast()
- })
- .map((), |_, ((this, _), _)| match this.inner {
- Inner::Temp => todo!(),
- Inner::Init(_) => todo!(),
- Inner::Error(err) => Err(err),
- Inner::Done => Ok(()),
- })
- .cast()
}
}
@@ -151,12 +158,9 @@ any_trait! {
impl<'ctx, T, E: Environment> DeserializerWalker<'ctx, T, E>
where
T: Deserializer<'ctx> + 'ctx,
- E: EnvConfig<NeedSend = No, NeedSync = No>
+ E: EnvConfig<NeedSend = No, NeedSync = No>,
{
- fn call_deserialize<'visitor: 'e, 'e, F>(
- &'e mut self,
- f: F,
- ) -> NativeForm<'e, VisitResult, E>
+ fn call_deserialize<'visitor: 'e, 'e, F>(&'e mut self, f: F) -> NativeForm<'e, VisitResult, E>
where
'ctx: 'visitor,
F: FnOnce(
@@ -169,17 +173,19 @@ where
match core::mem::replace(&mut self.inner, Inner::Temp) {
Inner::Init(deserializer) => {
match f(deserializer.0) {
- Ok(eff) => eff.map(self, |this, result| match result {
- (None, result) => {
- // Return the flow the visitor decided on.
- this.inner = Inner::Done;
- result
- }
- (Some(err), _) => {
- this.inner = Inner::Error(DeserializerWalkerError { inner: err });
- Flow::Err.into()
- }
- }).cast::<()>(),
+ Ok(eff) => eff
+ .map(self, |this, result| match result {
+ (None, result) => {
+ // Return the flow the visitor decided on.
+ this.inner = Inner::Done;
+ result
+ }
+ (Some(err), _) => {
+ this.inner = Inner::Error(DeserializerWalkerError { inner: err });
+ Flow::Err.into()
+ }
+ })
+ .cast::<()>(),
Err(err) => {
self.inner = Inner::Error(DeserializerWalkerError {
inner: VisitorError::Serde(Dynamic(err)),
@@ -253,7 +259,7 @@ impl_hints! {
impl<'ctx, T, E: Environment> Hint<'ctx, TagProto<tags::Map, E>> for DeserializerWalker<'ctx, T, E>
where
T: Deserializer<'ctx> + 'ctx,
- E: EnvConfig<NeedSend = No, NeedSync = No>
+ E: EnvConfig<NeedSend = No, NeedSync = No>,
{
fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
&'this mut self,
@@ -392,10 +398,9 @@ where
where
A: MapAccess<'ctx>,
{
- E::value((self, MapScope { map: Dynamic(map) }))
- .update((), |_, (this, scope)| {
- visit_sequence(this.visitor.cast(), scope).cast()
- });
+ E::value((self, MapScope { map: Dynamic(map) })).update((), |_, (this, scope)| {
+ visit_sequence(this.visitor.cast(), scope).cast()
+ });
todo!()
}
@@ -403,13 +408,13 @@ where
#[derive(SendSync)]
struct MapScope<A> {
- map: Dynamic<A>
+ map: Dynamic<A>,
}
-impl<'ctx, A, E: Environment> SequenceScope<'ctx, E> for MapScope<A>
+impl<'ctx, A, E: Environment> SequenceScope<'ctx, E> for MapScope<A>
where
E: EnvConfig<NeedSend = No, NeedSync = No>,
- A: MapAccess<'ctx>
+ A: MapAccess<'ctx>,
{
fn size_hint(&mut self) -> NativeForm<'_, (usize, Option<usize>), E> {
E::value((0, self.map.0.size_hint())).cast()
@@ -420,7 +425,8 @@ where
visitor: DynVisitor<'b, 'ctx, E>,
) -> NativeForm<'c, Flow, E>
where
- 'ctx: 'c + 'a + 'b {
+ 'ctx: 'c + 'a + 'b,
+ {
todo!()
}
}
diff --git a/tests/builder_enum.rs b/tests/builder_enum.rs
index fed91e0..093691f 100644
--- a/tests/builder_enum.rs
+++ b/tests/builder_enum.rs
@@ -18,7 +18,10 @@ use crate::common::{
};
use effectful::{
- effective::Effective, environment::{Environment, NativeForm}, SendSync, bound::Dynamic
+ bound::Dynamic,
+ effective::Effective,
+ environment::{Environment, NativeForm},
+ SendSync,
};
use macro_rules_attribute::derive;
diff --git a/tests/common/builder.rs b/tests/common/builder.rs
index d4fc3c7..7a07898 100644
--- a/tests/common/builder.rs
+++ b/tests/common/builder.rs
@@ -1,6 +1,9 @@
use core::fmt::{Debug, Display};
use effectful::{
- bound::{Bool, Dynamic, DynamicShim, IsSend, IsSync}, effective::Effective, environment::{DynBind, Environment, NativeForm}, forward_send_sync, SendSync
+ bound::{Bool, Dynamic, DynamicShim, IsSend, IsSync},
+ effective::Effective,
+ environment::{DynBind, Environment, NativeForm},
+ forward_send_sync, SendSync,
};
use mockall::mock;
use treaty::{
@@ -72,15 +75,10 @@ impl<Seed: 'static, Value: 'static, Error: 'static, E: Environment>
}
}
-impl<
- 'ctx,
- Seed: DynBind<E>,
- Value,
- Error: DynBind<E> + Display + Debug,
- E: Environment,
- > Builder<'ctx, E> for MockBuilder<Seed, Value, Error, E>
+impl<'ctx, Seed: DynBind<E>, Value, Error: DynBind<E> + Display + Debug, E: Environment>
+ Builder<'ctx, E> for MockBuilder<Seed, Value, Error, E>
where
- Dynamic<Value>: DynBind<E>
+ Dynamic<Value>: DynBind<E>,
{
fn from_seed<'a>(seed: Self::Seed) -> NativeForm<'a, Self, E>
where
@@ -102,7 +100,7 @@ impl<'ctx, Seed, Value, Error: Display + Debug, E: Environment> AsVisitor<'ctx,
where
Seed: DynBind<E>,
Error: DynBind<E>,
- Dynamic<Value>: DynBind<E>
+ Dynamic<Value>: DynBind<E>,
{
fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'ctx, E>
where
diff --git a/tests/common/protocol/request_hint.rs b/tests/common/protocol/request_hint.rs
index 9ba68f7..65ac8db 100644
--- a/tests/common/protocol/request_hint.rs
+++ b/tests/common/protocol/request_hint.rs
@@ -1,7 +1,8 @@
use effectful::{
bound::{Bool, IsSend, IsSync},
effective::Effective,
- environment::{Environment, NativeForm}, forward_send_sync,
+ environment::{Environment, NativeForm},
+ forward_send_sync,
};
use mockall::mock;
use treaty::{
diff --git a/tests/common/protocol/sequence.rs b/tests/common/protocol/sequence.rs
index 12b4e05..ab29c5c 100644
--- a/tests/common/protocol/sequence.rs
+++ b/tests/common/protocol/sequence.rs
@@ -1,7 +1,8 @@
use effectful::{
bound::{Bool, IsSend, IsSync},
effective::Effective,
- environment::{Environment, NativeForm}, forward_send_sync,
+ environment::{Environment, NativeForm},
+ forward_send_sync,
};
use mockall::mock;
use treaty::{
diff --git a/tests/common/protocol/tag.rs b/tests/common/protocol/tag.rs
index 4c17eda..96e75b2 100644
--- a/tests/common/protocol/tag.rs
+++ b/tests/common/protocol/tag.rs
@@ -51,8 +51,8 @@ where
T: AsVisitor<'ctx, Blocking>,
{
fn visit_tag_and_done<'a, const TAG: u64, W: Walker<'ctx, Blocking>>(&'a mut self, walker: W) {
- let result =
- visit_tag::<TagConst<TAG>, Blocking, _>(TagConst, self.as_visitor(), walker).into_value();
+ let result = visit_tag::<TagConst<TAG>, Blocking, _>(TagConst, self.as_visitor(), walker)
+ .into_value();
assert_eq!(result.unwrap(), VisitResult::Control(Flow::Done));
}
diff --git a/tests/common/protocol/value.rs b/tests/common/protocol/value.rs
index 4f1e5c9..b5b4031 100644
--- a/tests/common/protocol/value.rs
+++ b/tests/common/protocol/value.rs
@@ -1,7 +1,7 @@
use effectful::{
- environment::{Environment, NativeForm, DynBind},
- bound::{Bool, IsSend, IsSync, Dynamic},
+ bound::{Bool, Dynamic, IsSend, IsSync},
effective::Effective,
+ environment::{DynBind, Environment, NativeForm},
forward_send_sync,
};
use mockall::mock;
@@ -54,7 +54,8 @@ where
E::value(match self.visit(&value) {
VisitResult::Skipped(_) => VisitResult::Skipped(Dynamic(value)),
VisitResult::Control(flow) => VisitResult::Control(flow),
- }).cast()
+ })
+ .cast()
}
}
diff --git a/tests/common/walker.rs b/tests/common/walker.rs
index b64e0f6..449a102 100644
--- a/tests/common/walker.rs
+++ b/tests/common/walker.rs
@@ -1,7 +1,7 @@
use effectful::{
- effective::Effective,
bound::{Bool, IsSend, IsSync},
- environment::{Environment, NativeForm, DynBind},
+ effective::Effective,
+ environment::{DynBind, Environment, NativeForm},
forward_send_sync,
};
use mockall::mock;
@@ -23,8 +23,8 @@ mock! {
forward_send_sync!({Output, Error} {} {E: (Environment)} MockWalker<Output, Error, E>);
-impl<'ctx, Output: DynBind<E>, Error: DynBind<E> + core::fmt::Debug, E: Environment>
- Walker<'ctx, E> for MockWalker<Output, Error, E>
+impl<'ctx, Output: DynBind<E>, Error: DynBind<E> + core::fmt::Debug, E: Environment> Walker<'ctx, E>
+ for MockWalker<Output, Error, E>
{
type Error = Error;
@@ -41,7 +41,9 @@ impl<'ctx, Output: DynBind<E>, Error: DynBind<E> + core::fmt::Debug, E: Environm
}
}
-impl<'ctx, Output: DynBind<E>, Error: DynBind<E>, E: Environment> AnyTrait<'ctx, E> for MockWalker<Output, Error, E> {
+impl<'ctx, Output: DynBind<E>, Error: DynBind<E>, E: Environment> AnyTrait<'ctx, E>
+ for MockWalker<Output, Error, E>
+{
fn upcast_to_id<'a>(
&'a self,
id: TypeNameId,
diff --git a/tests/protocol_visitor_recoverable.rs b/tests/protocol_visitor_recoverable.rs
index 3979110..3dc382e 100644
--- a/tests/protocol_visitor_recoverable.rs
+++ b/tests/protocol_visitor_recoverable.rs
@@ -27,10 +27,16 @@ fn recoverable_can_be_visited() {
visitor.expect_traits().times(2).return_const(None);
// Attempt to walk once.
- assert_eq!(scope.new_walk(DynVisitor(&mut visitor)).into_value(), Status::Ok);
+ assert_eq!(
+ scope.new_walk(DynVisitor(&mut visitor)).into_value(),
+ Status::Ok
+ );
// Attempt to walk twice.
- assert_eq!(scope.new_walk(DynVisitor(&mut visitor)).into_value(), Status::Ok);
+ assert_eq!(
+ scope.new_walk(DynVisitor(&mut visitor)).into_value(),
+ Status::Ok
+ );
// We are done.
VisitResult::Control(Flow::Done)
diff --git a/tests/protocol_visitor_request_hint.rs b/tests/protocol_visitor_request_hint.rs
index 783c37e..db39a2b 100644
--- a/tests/protocol_visitor_request_hint.rs
+++ b/tests/protocol_visitor_request_hint.rs
@@ -15,8 +15,8 @@ use treaty::{
Flow,
};
-use effectful::bound::Dynamic;
use crate::common::{protocol::hint::KnownFactory, Blocking};
+use effectful::bound::Dynamic;
mod common;
@@ -52,7 +52,8 @@ fn hints_can_be_requested() {
mock.expect_traits_mut()
.once()
.with(eq(TypeNameId::of::<
- HintProto<ValueProto<OwnedStatic<i32>, Blocking>>, Blocking
+ HintProto<ValueProto<OwnedStatic<i32>, Blocking>>,
+ Blocking,
>()))
.returning(|_id| {
let mut mock = MockHintWalker::<ValueProto<OwnedStatic<i32>, Blocking>>::new();
diff --git a/tests/protocol_visitor_sequence.rs b/tests/protocol_visitor_sequence.rs
index 4b3e7ca..dbc613b 100644
--- a/tests/protocol_visitor_sequence.rs
+++ b/tests/protocol_visitor_sequence.rs
@@ -29,7 +29,10 @@ fn sequence_has_scope_with_size_hint_and_next() {
visitor.expect_traits().once().return_const(None);
// Get the next item in the sequence from the walker.
- assert_eq!(scope.next(DynVisitor(&mut visitor)).into_value(), Flow::Done);
+ assert_eq!(
+ scope.next(DynVisitor(&mut visitor)).into_value(),
+ Flow::Done
+ );
// We are done.
VisitResult::Control(Flow::Done)
diff --git a/tests/protocol_visitor_tag.rs b/tests/protocol_visitor_tag.rs
index 544f4c2..8838086 100644
--- a/tests/protocol_visitor_tag.rs
+++ b/tests/protocol_visitor_tag.rs
@@ -33,7 +33,10 @@ fn tag_can_be_visited() {
builder.expect_traits().once().return_const(None);
// Walk the value of the tag.
- assert_eq!(walker.walk(DynVisitor(&mut builder)).into_value(), Flow::Done);
+ assert_eq!(
+ walker.walk(DynVisitor(&mut builder)).into_value(),
+ Flow::Done
+ );
// We are done.
VisitResult::Control(Flow::Done)
@@ -81,7 +84,10 @@ fn const_tag_can_be_visited() {
builder.expect_traits().once().return_const(None);
// Walk the value of the tag.
- assert_eq!(walker.walk(DynVisitor(&mut builder)).into_value(), Flow::Done);
+ assert_eq!(
+ walker.walk(DynVisitor(&mut builder)).into_value(),
+ Flow::Done
+ );
// We are done.
VisitResult::Control(Flow::Done)
diff --git a/tests/protocol_visitor_value.rs b/tests/protocol_visitor_value.rs
index 13e6367..1f2dd15 100644
--- a/tests/protocol_visitor_value.rs
+++ b/tests/protocol_visitor_value.rs
@@ -4,8 +4,8 @@ use common::protocol::{
hint::{KnownFactory, MockHintWalker},
value::MockValueVisitor,
};
-use effectful::SendSync;
use effectful::bound::Dynamic;
+use effectful::SendSync;
use mockall::predicate::eq;
use treaty::{
any::{
@@ -144,7 +144,9 @@ fn temp_borrowed_value() {
// Visit the temp value.
assert_eq!(
- visitor.visit(TempBorrowedMutStatic(&mut value)).into_value(),
+ visitor
+ .visit(TempBorrowedMutStatic(&mut value))
+ .into_value(),
Flow::Done.into()
);
}
@@ -284,6 +286,9 @@ fn as_hint() {
let walker: &mut dyn Hint<ValueProto<TempBorrowedMutStaticHrt<i32>, Blocking>> = &mut mock;
// The value protocol has no hint data, and it has no known data.
- assert_eq!(walker.known(&()).into_value(), Ok(ValueKnown { preview: None }));
+ assert_eq!(
+ walker.known(&()).into_value(),
+ Ok(ValueKnown { preview: None })
+ );
}
}
diff --git a/tests/serde_deserializer.rs b/tests/serde_deserializer.rs
index ee9d7ae..acb2e56 100644
--- a/tests/serde_deserializer.rs
+++ b/tests/serde_deserializer.rs
@@ -1,9 +1,9 @@
use serde_json::json;
use treaty::walkers::serde::deserializer::DeserializerWalker;
-use treaty::{Build, BuildExt as _, transform};
+use treaty::{transform, Build, BuildExt as _};
-use macro_rules_attribute::derive;
use effectful::SendSync;
+use macro_rules_attribute::derive;
mod common;
@@ -18,8 +18,6 @@ fn demo() {
#[test]
fn demo2() {
- let x = json!(42);
-
let mut de = serde_json::Deserializer::from_str("42");
let y = u8::build(DeserializerWalker::new(&mut de));
diff --git a/tests/walker_struct.rs b/tests/walker_struct.rs
index 01ae867..833b2dd 100644
--- a/tests/walker_struct.rs
+++ b/tests/walker_struct.rs
@@ -1,5 +1,8 @@
use effectful::{
- bound::{DynamicShim, ForceDynamic, Dynamic}, effective::Effective, environment::{Environment, NativeForm, DynBind}, SendSync
+ bound::{Dynamic, DynamicShim, ForceDynamic},
+ effective::Effective,
+ environment::{DynBind, Environment, NativeForm},
+ SendSync,
};
use mockall::predicate::eq;
use treaty::{
@@ -29,7 +32,7 @@ struct X {
struct Info;
// This gives the struct walker enough information to walk the X struct.
-impl<'ctx, M, E: Environment> StructTypeInfo<'ctx, M, E> for Info
+impl<'ctx, M, E: Environment> StructTypeInfo<'ctx, M, E> for Info
where
Dynamic<OwnedStatic<bool>>: DynBind<E>,
Dynamic<OwnedStatic<i32>>: DynBind<E>,
@@ -49,42 +52,44 @@ where
value: &'ctx Self::T,
mut visitor: DynVisitor<'a, 'ctx, E>,
) -> NativeForm<'a, Result<Flow, Self::FieldError>, E> {
- E::future(unsafe { ForceDynamic::new(async move {
- match index {
- // A real impl would be expected to tag these values with the field name.
- 0 => {
- // Basic visit for the field value.
- let obj = visitor
- .upcast_mut::<ValueProto<OwnedStatic<bool>, E>>()
- .unwrap();
-
- // Emit the field value.
- assert_eq!(
- obj.visit(OwnedStatic(value.a)).into_future().await,
- Flow::Done.into()
- );
-
- // There are more fields.
- Ok(Flow::Continue)
+ E::future(unsafe {
+ ForceDynamic::new(async move {
+ match index {
+ // A real impl would be expected to tag these values with the field name.
+ 0 => {
+ // Basic visit for the field value.
+ let obj = visitor
+ .upcast_mut::<ValueProto<OwnedStatic<bool>, E>>()
+ .unwrap();
+
+ // Emit the field value.
+ assert_eq!(
+ obj.visit(OwnedStatic(value.a)).into_future().await,
+ Flow::Done.into()
+ );
+
+ // There are more fields.
+ Ok(Flow::Continue)
+ }
+ 1 => {
+ // Basic visit for the field value.
+ let obj = visitor
+ .upcast_mut::<ValueProto<OwnedStatic<i32>, E>>()
+ .unwrap();
+
+ // Emit the field value.
+ assert_eq!(
+ obj.visit(OwnedStatic(value.b)).into_future().await,
+ Flow::Done.into()
+ );
+
+ // There are no more fields.
+ Ok(Flow::Done)
+ }
+ _ => Ok(Flow::Done),
}
- 1 => {
- // Basic visit for the field value.
- let obj = visitor
- .upcast_mut::<ValueProto<OwnedStatic<i32>, E>>()
- .unwrap();
-
- // Emit the field value.
- assert_eq!(
- obj.visit(OwnedStatic(value.b)).into_future().await,
- Flow::Done.into()
- );
-
- // There are no more fields.
- Ok(Flow::Done)
- }
- _ => Ok(Flow::Done),
- }
- })})
+ })
+ })
.cast()
}
}
@@ -156,9 +161,10 @@ fn sequence_of_field_values() {
visitor
.expect_traits_mut()
.once()
- .with(eq(
- TypeNameId::of::<ValueProto<OwnedStatic<i32>, Blocking>, Blocking>(),
- ))
+ .with(eq(TypeNameId::of::<
+ ValueProto<OwnedStatic<i32>, Blocking>,
+ Blocking,
+ >()))
.returning(|_| {
let mut visitor = MockValueVisitor::<OwnedStatic<i32>, Blocking>::new();
@@ -190,7 +196,9 @@ fn sequence_of_field_values() {
// Walk the struct.
assert_eq!(
- walker.walk(AsVisitor::as_visitor(&mut builder)).into_value(),
+ walker
+ .walk(AsVisitor::as_visitor(&mut builder))
+ .into_value(),
Ok(())
);
}
@@ -219,7 +227,10 @@ fn has_struct_tag() {
.expect_traits_mut()
.once()
.in_sequence(&mut seq)
- .with(eq(TypeNameId::of::<TagProto<tags::Struct, Blocking>, Blocking>()))
+ .with(eq(TypeNameId::of::<
+ TagProto<tags::Struct, Blocking>,
+ Blocking,
+ >()))
.returning(|_| {
let mut visitor = MockTagVisitor::<tags::Struct, Blocking>::new();
@@ -227,7 +238,10 @@ fn has_struct_tag() {
let mut visitor = MockBuilder::<(), (), (), Blocking>::new();
// Walk the noop walker so there isn't an error.
- assert_eq!(walker.walk(DynVisitor(&mut visitor)).into_value(), Flow::Done);
+ assert_eq!(
+ walker.walk(DynVisitor(&mut visitor)).into_value(),
+ Flow::Done
+ );
// We are done, the walker should now stop early.
VisitResult::Control(Flow::Done)
@@ -238,7 +252,9 @@ fn has_struct_tag() {
// Walk the struct.
assert_eq!(
- walker.walk(AsVisitor::as_visitor(&mut builder)).into_value(),
+ walker
+ .walk(AsVisitor::as_visitor(&mut builder))
+ .into_value(),
Ok(())
);
}
@@ -269,7 +285,9 @@ fn has_map_backup_tag() {
.expect_traits_mut()
.once()
.in_sequence(&mut seq)
- .with(eq(TypeNameId::of::<TagProto<tags::Map, Blocking>, Blocking>()))
+ .with(eq(
+ TypeNameId::of::<TagProto<tags::Map, Blocking>, Blocking>(),
+ ))
.returning(|_| {
let mut visitor = MockTagVisitor::<tags::Map, Blocking>::new();
@@ -277,7 +295,10 @@ fn has_map_backup_tag() {
let mut visitor = MockBuilder::<(), (), (), Blocking>::new();
// Walk the noop walker so there isn't an error.
- assert_eq!(walker.walk(DynVisitor(&mut visitor)).into_value(), Flow::Done);
+ assert_eq!(
+ walker.walk(DynVisitor(&mut visitor)).into_value(),
+ Flow::Done
+ );
// We are done, the walker should now stop early.
VisitResult::Control(Flow::Done)
@@ -288,7 +309,9 @@ fn has_map_backup_tag() {
// Walk the struct.
assert_eq!(
- walker.walk(AsVisitor::as_visitor(&mut builder)).into_value(),
+ walker
+ .walk(AsVisitor::as_visitor(&mut builder))
+ .into_value(),
Ok(())
);
}
@@ -318,7 +341,8 @@ fn borrowed_value_directly() {
.once()
.in_sequence(&mut seq)
.with(eq(TypeNameId::of::<
- ValueProto<BorrowedStaticHrt<X>, Blocking>, Blocking
+ ValueProto<BorrowedStaticHrt<X>, Blocking>,
+ Blocking,
>()))
.returning(|_| {
let mut visitor = MockValueVisitor::<BorrowedStaticHrt<X>, Blocking>::new();
@@ -341,7 +365,9 @@ fn borrowed_value_directly() {
// Walk the struct.
assert_eq!(
- walker.walk(AsVisitor::as_visitor(&mut builder)).into_value(),
+ walker
+ .walk(AsVisitor::as_visitor(&mut builder))
+ .into_value(),
Ok(())
);
}