diff --git a/src/flow/traversible/unbalanced.rs b/src/flow/traversible/unbalanced.rs index 65a2071..917690e 100644 --- a/src/flow/traversible/unbalanced.rs +++ b/src/flow/traversible/unbalanced.rs @@ -53,8 +53,8 @@ where { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - UnbalancedTree::Leaf => write!(f, "."), - UnbalancedTree::Node(reference) => write!(f, "{}", reference), + Self::Leaf => write!(f, "."), + Self::Node(reference) => write!(f, "{}", reference), } } } @@ -109,8 +109,8 @@ impl<'a, T: Monad<'a>, A: 'a + Clone> TraversibleBinaryTree<'a, T, A, Unbalanced { fn refer(&self) -> Option>> { match self { - UnbalancedTree::Leaf => None, - UnbalancedTree::Node(reference) => Some(reference.clone()), + Self::Leaf => None, + Self::Node(reference) => Some(reference.clone()), } } } diff --git a/src/func/instances/stackless.rs b/src/func/instances/stackless.rs index bbd6135..ef50c50 100644 --- a/src/func/instances/stackless.rs +++ b/src/func/instances/stackless.rs @@ -20,16 +20,15 @@ type Oet<'a> = Option>; impl<'a> EvalTree<'a> { fn next(self) -> Oet<'a> { match self { - EvalTree::Atom(f) => f(), - EvalTree::Composite(etl, etr) => match *etl { - EvalTree::Atom(f) => match f() { - Some(newleft) => Some(EvalTree::Composite(Box::new(newleft), etr)), + Self::Atom(f) => f(), + Self::Composite(etl, etr) => match *etl { + Self::Atom(f) => match f() { + Some(newleft) => Some(Self::Composite(Box::new(newleft), etr)), None => Some(*etr), }, - EvalTree::Composite(etll, etlr) => Some(EvalTree::Composite( - etll, - Box::new(EvalTree::Composite(etlr, etr)), - )), + Self::Composite(etll, etlr) => { + Some(Self::Composite(etll, Box::new(Self::Composite(etlr, etr)))) + } }, } } diff --git a/src/func/tests.rs b/src/func/tests.rs index 6298f86..117ef71 100644 --- a/src/func/tests.rs +++ b/src/func/tests.rs @@ -16,7 +16,7 @@ pub type R = TestResults; impl R { pub fn unwrap(self) { match self { - TestResults { + Self { success, total, result: Err(e), diff --git a/src/rcore/resolution.rs b/src/rcore/resolution.rs index 4a3ec50..7e26d50 100644 --- a/src/rcore/resolution.rs +++ b/src/rcore/resolution.rs @@ -12,8 +12,8 @@ pub enum ResolutionError { impl ResolutionError { pub fn map_parse(self, f: impl FnOnce(P) -> Px) -> ResolutionError { match self { - ResolutionError::Lookup(l) => ResolutionError::Lookup(l), - ResolutionError::Parse(p) => ResolutionError::Parse(f(p)), + Self::Lookup(l) => ResolutionError::Lookup(l), + Self::Parse(p) => ResolutionError::Parse(f(p)), } } } diff --git a/src/rstd/cast.rs b/src/rstd/cast.rs index 52a620c..bffc711 100644 --- a/src/rstd/cast.rs +++ b/src/rstd/cast.rs @@ -40,13 +40,13 @@ pub enum CastError<'a> { impl<'a> Display for CastError<'a> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - CastError::Typeless(typeless_error) => { + Self::Typeless(typeless_error) => { write!(f, "typeless cast error: {}", typeless_error) } - CastError::AddressIndexOutOfBounds { index, length } => { + Self::AddressIndexOutOfBounds { index, length } => { write!(f, "cast index out of bound: {}>={}", index, length) } - CastError::AddressPointMismatch { + Self::AddressPointMismatch { expected, received, index, diff --git a/src/rstd/collections/pair.rs b/src/rstd/collections/pair.rs index 3e9cbb7..0724178 100644 --- a/src/rstd/collections/pair.rs +++ b/src/rstd/collections/pair.rs @@ -37,10 +37,10 @@ pub enum PairParseError { impl Display for PairParseError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - PairParseError::A(error) => { + Self::A(error) => { write!(f, "error while parsing first element of a pair: {}", error) } - PairParseError::B(error) => { + Self::B(error) => { write!(f, "error while parsing second element of a pair: {}", error) } } diff --git a/src/rstd/collections/rbtree/subset.rs b/src/rstd/collections/rbtree/subset.rs deleted file mode 100644 index eea0b20..0000000 --- a/src/rstd/collections/rbtree/subset.rs +++ /dev/null @@ -1,162 +0,0 @@ -use std::rc::Rc; - -use crate::flow::traversible::*; -use crate::func::*; -use crate::rstd::fallible::*; - -use super::*; - -pub type TPE<'a, Ctx, A> = TreeParseError>>; - -pub type TreeFaiure<'a, Ctx, A> = - ResolutionError<>::LookupError, TPE<'a, Ctx, A>>; - -pub type SubsetWrapped<'a, Ctx, A> = FallibleWrapped<'a, Ctx, bool, TreeFaiure<'a, Ctx, A>>; - -pub type SubsetMonad<'a, Ctx, A> = FallibleMonad<'a, Ctx, TreeFaiure<'a, Ctx, A>>; - -pub fn subset_pure<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>>( - value: bool, -) -> SubsetWrapped<'a, Ctx, A> { - as Pure>::pure(value) -} - -#[derive(PartialEq)] -enum NodeType { - Rb, - R, - B, -} - -type RefData = (NodeType, Hash); - -impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> - TraversibleBinaryNode<'a, SubsetMonad<'a, Ctx, A>, A, RefData> for BNode<'a, Ctx, A> -{ - fn split(&self) -> Split<'a, SubsetMonad<'a, Ctx, A>, A, RefData> { - ( - Rc::new(self.cl.clone()), - Rc::new(self.cr.clone()), - self.key.clone(), - ) - } - - fn to_tree( - self: Rc, - ) -> Rc, A, RefData>> { - Rc::new(Nullable::from(self)) - } -} - -impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> - TraversibleBinaryNode<'a, SubsetMonad<'a, Ctx, A>, A, RefData> for RNode<'a, Ctx, A> -{ - fn split(&self) -> Split<'a, SubsetMonad<'a, Ctx, A>, A, RefData> { - ( - Rc::new(self.cl.clone()), - Rc::new(self.cr.clone()), - self.key.clone(), - ) - } - - fn to_tree( - self: Rc, - ) -> Rc, A, RefData>> { - Rc::new(Nullable::from(self)) - } -} - -impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> - TraversibleBinaryNode<'a, SubsetMonad<'a, Ctx, A>, A, RefData> for RBNode<'a, Ctx, A> -{ - fn split(&self) -> Split<'a, SubsetMonad<'a, Ctx, A>, A, RefData> { - match self { - RBNode::R(r) => r.split(), - RBNode::B(b) => b.split(), - } - } - - fn to_tree( - self: Rc, - ) -> Rc, A, RefData>> { - Rc::new(Nullable::from(self)) - } -} - -impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> - TraversibleBinaryReference<'a, SubsetMonad<'a, Ctx, A>, A, RefData> - for Point<'a, Ctx, BNode<'a, Ctx, A>> -{ - fn resolve( - &self, - ) -> Wrap< - 'a, - Rc, A, RefData>>, - SubsetMonad<'a, Ctx, A>, - > { - as Functor>::fmap(Ctx::stuff(self.resolve()), |resolved| { - resolved as Rc> - }) - } - - fn data(&self) -> RefData { - (NodeType::B, self.point) - } -} - -impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> - TraversibleBinaryReference<'a, SubsetMonad<'a, Ctx, A>, A, RefData> - for Point<'a, Ctx, RNode<'a, Ctx, A>> -{ - fn resolve( - &self, - ) -> Wrap< - 'a, - Rc, A, RefData>>, - SubsetMonad<'a, Ctx, A>, - > { - as Functor>::fmap(Ctx::stuff(self.resolve()), |resolved| { - resolved as Rc> - }) - } - - fn data(&self) -> RefData { - (NodeType::R, self.point) - } -} - -impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> - TraversibleBinaryReference<'a, SubsetMonad<'a, Ctx, A>, A, RefData> - for Point<'a, Ctx, RBNode<'a, Ctx, A>> -{ - fn resolve( - &self, - ) -> Wrap< - 'a, - Rc, A, RefData>>, - SubsetMonad<'a, Ctx, A>, - > { - as Functor>::fmap(Ctx::stuff(self.resolve()), |resolved| { - resolved as Rc> - }) - } - - fn data(&self) -> RefData { - (NodeType::Rb, self.point) - } -} - -impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>, T: Mentionable<'a, Ctx>, D: 'a + PartialEq> - TraversibleBinaryTree<'a, SubsetMonad<'a, Ctx, A>, A, D> for Nullable<'a, Ctx, T> -where - Point<'a, Ctx, T>: TraversibleBinaryReference<'a, SubsetMonad<'a, Ctx, A>, A, D>, -{ - fn refer( - &self, - ) -> Option, A, D>>> { - match self { - Nullable::Null(_) => None, - Nullable::NotNull(point) => Some(Rc::new(point.clone())), - } - } -} diff --git a/src/rstd/nullable.rs b/src/rstd/nullable.rs index e075b34..78257d3 100644 --- a/src/rstd/nullable.rs +++ b/src/rstd/nullable.rs @@ -22,8 +22,8 @@ pub struct NullableFactory { impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Serializable for Nullable<'a, Ctx, A> { fn serialize(&self, serializer: &mut dyn Serializer) { serializer.write(match self { - Nullable::Null(_) => &HASH_ZEROS, - Nullable::NotNull(point) => &point.point, + Self::Null(_) => &HASH_ZEROS, + Self::NotNull(point) => &point.point, }) } } @@ -33,10 +33,10 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Nul fn factory(&self) -> Self::Fctr { match self { - Nullable::Null(factory) => NullableFactory { + Self::Null(factory) => NullableFactory { factory: factory.clone(), }, - Nullable::NotNull(point) => NullableFactory { + Self::NotNull(point) => NullableFactory { factory: point.origin.factory(), }, } @@ -44,8 +44,8 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Nul fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) { match self { - Nullable::Null(_) => {} - Nullable::NotNull(point) => points.take(point), + Self::Null(_) => {} + Self::NotNull(point) => points.take(point), } } } diff --git a/src/rstd/tracing/rendered.rs b/src/rstd/tracing/rendered.rs index 4b6d6b4..325d4fa 100644 --- a/src/rstd/tracing/rendered.rs +++ b/src/rstd/tracing/rendered.rs @@ -102,8 +102,8 @@ impl WithLengthAndWidth { impl RenderedWide { fn any(self) -> RenderedAny { match self { - RenderedWide::Common(common) => RenderedAny::Common(common), - RenderedWide::Wide(vec) => RenderedAny::Wide(vec), + Self::Common(common) => RenderedAny::Common(common), + Self::Wide(vec) => RenderedAny::Wide(vec), } } } @@ -111,8 +111,8 @@ impl RenderedWide { impl RenderedLong { fn any(self) -> RenderedAny { match self { - RenderedLong::Common(common) => RenderedAny::Common(common), - RenderedLong::Long(vec) => RenderedAny::Long(vec), + Self::Common(common) => RenderedAny::Common(common), + Self::Long(vec) => RenderedAny::Long(vec), } } } @@ -191,10 +191,10 @@ impl RenderedCommon { impl RenderedCommon { fn rectangles(self, vec: &mut Vec<(usize, usize)>, t: usize, c: usize) { match self { - RenderedCommon::Empty => {} - RenderedCommon::Resolution => vec.push((t, c)), - RenderedCommon::Event(_) => {} - RenderedCommon::Action { rendered, .. } => rendered.rectangles(vec, t, c), + Self::Empty => {} + Self::Resolution => vec.push((t, c)), + Self::Event(_) => {} + Self::Action { rendered, .. } => rendered.rectangles(vec, t, c), } } } diff --git a/src/rstd/tracing/trace.rs b/src/rstd/tracing/trace.rs index 73e2779..f89d07d 100644 --- a/src/rstd/tracing/trace.rs +++ b/src/rstd/tracing/trace.rs @@ -20,7 +20,7 @@ pub struct TraceBox { impl Trace { fn fmt_parallel(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Trace::Parallel(a, b) => { + Self::Parallel(a, b) => { write!(f, "{} | {}", ParallelBox(a), ParallelBox(b)) } trace => write!(f, "{}", trace), @@ -29,7 +29,7 @@ impl Trace { fn fmt_sequential(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Trace::Sequential { first, second } => { + Self::Sequential { first, second } => { write!(f, "{} > {}", SequentialBox(first), SequentialBox(second)) } trace => write!(f, "{}", trace), diff --git a/src/rstd/tracing/trace/render.rs b/src/rstd/tracing/trace/render.rs index e75ab5f..20d229e 100644 --- a/src/rstd/tracing/trace/render.rs +++ b/src/rstd/tracing/trace/render.rs @@ -18,15 +18,15 @@ enum TraceAny<'a> { impl Trace { fn any(&self) -> TraceAny<'_> { match self { - Trace::Pure => TraceAny::Common(TraceCommon::Pure), - Trace::InvolvesOneResolution => TraceAny::Common(TraceCommon::InvolvesOneResolution), - Trace::Event(event) => TraceAny::Common(TraceCommon::Event(event)), - Trace::Wrapped { name, trace } => TraceAny::Common(TraceCommon::Wrapped { + Self::Pure => TraceAny::Common(TraceCommon::Pure), + Self::InvolvesOneResolution => TraceAny::Common(TraceCommon::InvolvesOneResolution), + Self::Event(event) => TraceAny::Common(TraceCommon::Event(event)), + Self::Wrapped { name, trace } => TraceAny::Common(TraceCommon::Wrapped { name, trace: &trace.trace, }), - Trace::Parallel(a, b) => TraceAny::Parallel(&a.trace, &b.trace), - Trace::Sequential { first, second } => TraceAny::Sequential { + Self::Parallel(a, b) => TraceAny::Parallel(&a.trace, &b.trace), + Self::Sequential { first, second } => TraceAny::Sequential { first: &first.trace, second: &second.trace, }, @@ -67,9 +67,9 @@ fn from_parallel( impl<'a> TraceAny<'a> { fn render(&'a self) -> WithLengthAndWidth { match self { - TraceAny::Common(common) => common.render().map(RenderedAny::Common), - TraceAny::Parallel(a, b) => from_parallel(a, b).map(RenderedAny::Wide), - TraceAny::Sequential { first, second } => { + Self::Common(common) => common.render().map(RenderedAny::Common), + Self::Parallel(a, b) => from_parallel(a, b).map(RenderedAny::Wide), + Self::Sequential { first, second } => { from_sequential(first, second).map(RenderedAny::Long) } } @@ -80,9 +80,9 @@ impl<'a> TraceAny<'a> { vec: &mut WithLengthAndWidth>>, ) { match self { - TraceAny::Common(common) => common.render().map(RenderedWide::Common).push_into(vec), - TraceAny::Parallel(a, b) => from_parallel(a, b).map(RenderedWide::Wide).push_into(vec), - TraceAny::Sequential { first, second } => { + Self::Common(common) => common.render().map(RenderedWide::Common).push_into(vec), + Self::Parallel(a, b) => from_parallel(a, b).map(RenderedWide::Wide).push_into(vec), + Self::Sequential { first, second } => { first.any().render_into_long(vec); second.any().render_into_long(vec); } @@ -94,12 +94,12 @@ impl<'a> TraceAny<'a> { vec: &mut WithLengthAndWidth>>, ) { match self { - TraceAny::Common(common) => common.render().map(RenderedLong::Common).push_into(vec), - TraceAny::Parallel(a, b) => { + Self::Common(common) => common.render().map(RenderedLong::Common).push_into(vec), + Self::Parallel(a, b) => { a.any().render_into_wide(vec); b.any().render_into_wide(vec); } - TraceAny::Sequential { first, second } => from_sequential(first, second) + Self::Sequential { first, second } => from_sequential(first, second) .map(RenderedLong::Long) .push_into(vec), } @@ -109,10 +109,10 @@ impl<'a> TraceAny<'a> { impl<'a> TraceCommon<'a> { fn render(&'a self) -> WithLengthAndWidth { match self { - TraceCommon::Pure => RenderedCommon::empty(), - TraceCommon::InvolvesOneResolution => RenderedCommon::resolution(), - TraceCommon::Event(event) => RenderedCommon::event(event), - TraceCommon::Wrapped { name, trace } => trace.any().render().wrap(name), + Self::Pure => RenderedCommon::empty(), + Self::InvolvesOneResolution => RenderedCommon::resolution(), + Self::Event(event) => RenderedCommon::event(event), + Self::Wrapped { name, trace } => trace.any().render().wrap(name), } } }