diff --git a/src/core.rs b/src/core.rs index 6c6dbc8..3c78d22 100644 --- a/src/core.rs +++ b/src/core.rs @@ -9,9 +9,8 @@ mod resolution; mod resolver_origin; mod serialization; mod slice_deserializer; -mod typeless; -use std::{error::Error, fmt::Display, rc::Rc}; +use std::{error::Error, rc::Rc}; use crate::func::*; @@ -21,7 +20,6 @@ pub use self::points::TakesPoints; pub use self::resolution::*; pub use self::serialization::*; pub use self::slice_deserializer::*; -pub use self::typeless::*; /// Basic support for tracing events across the execution. pub trait Diagnostic { @@ -72,8 +70,6 @@ pub trait Mentionable<'a, Ctx: 'a + Context>: 'a + Serializable { } /// References ([Point]s) to other objects. Typed. fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>); - /// References ([Point]s) to other objects. Typeless. - fn points(&self, points: &mut Vec>>); } /// Shorthand for the type of vaalues returned by [`Factory::deserialize`]. @@ -81,7 +77,7 @@ pub type ParseResult<'a, Ctx, F> = Result<>::Mtbl, >::ParseError>; /// Trait representing deserialisation rules for [Mentionable]s. -/// Crucial for [`TypelessMentionable`] and therefore [`Mentionable::points`]. +/// Crucial for [`crate::std::ctypeless`]. pub trait Factory<'a, Ctx: 'a + Context>: 'a + Send + Sync + Clone { /// Type of the associated objects. type Mtbl: Mentionable<'a, Ctx, Fctr = Self>; diff --git a/src/core/resolution.rs b/src/core/resolution.rs index 8a34e4e..f7f656a 100644 --- a/src/core/resolution.rs +++ b/src/core/resolution.rs @@ -32,7 +32,7 @@ pub type HashResolution<'a, Ctx> = Wrapped< #[derive(Clone, Copy, Debug)] pub struct Address { pub point: Hash, - /// Index of the point in the [`Mentionable::points()`]. + /// Index of the point in the [`Mentionable::points_typed()`]. pub index: usize, } diff --git a/src/std.rs b/src/std.rs index 4c517cb..b806f4f 100644 --- a/src/std.rs +++ b/src/std.rs @@ -3,6 +3,7 @@ pub mod atomic; pub mod cast; pub mod collections; +pub mod ctypeless; pub mod fallible; pub mod inlining; mod local_origin; diff --git a/src/std/atomic.rs b/src/std/atomic.rs index afb13b5..d958436 100644 --- a/src/std/atomic.rs +++ b/src/std/atomic.rs @@ -12,7 +12,8 @@ use crate::core::*; use super::*; /// This trait combines functionality of [`Mentionable`] and [`Factory`], -/// while limiting [`Mentionable::points`] (and corresponding [`Mentionable::topology`]) to an empty sequence. +/// while limiting [`Mentionable::points_typed`] (and corresponding [`Mentionable::topology`]) +/// to an empty sequence. pub trait Atomic: 'static + Send + Sync + Send + Clone + Serializable { /// Equivalent of [`Factory::ParseError`]. type AParseError: Error; diff --git a/src/std/atomic/atomic_object.rs b/src/std/atomic/atomic_object.rs index fcd3052..6235731 100644 --- a/src/std/atomic/atomic_object.rs +++ b/src/std/atomic/atomic_object.rs @@ -47,8 +47,6 @@ impl<'a, Ctx: 'a + Context, A: Atomic> Mentionable<'a, Ctx> for AtomicObject } fn points_typed(&self, _points: &mut impl TakesPoints<'a, Ctx>) {} - - fn points(&self, _points: &mut Vec>>) {} } /// Generic implementation of a [Factory] for [Atomic]s. diff --git a/src/std/cast.rs b/src/std/cast.rs index c223c60..ff22cf8 100644 --- a/src/std/cast.rs +++ b/src/std/cast.rs @@ -7,7 +7,7 @@ use std::convert::identity; use crate::core::*; -use super::{typeless::*, *}; +use super::{ctypeless::*, typeless::*, *}; struct CastResolver<'a, Ctx: 'a + Context> { points: Vec>>, @@ -23,7 +23,7 @@ pub enum CastError<'a> { /// If you don't know what that means, it's a good idea to [`panic!`]. /// Happens due to internal resolver using indices rather than `point`s. /// This error usually indicates inconsistent behaviour - /// of [`Mentionable::points`] and/or [`Mentionable::topology`]. + /// of [`Mentionable::points_typed`] and/or [`Mentionable::topology`]. AddressIndexOutOfBounds { index: usize, length: usize, diff --git a/src/std/collections/rbtree.rs b/src/std/collections/rbtree.rs index 6f727b1..0ccbef9 100644 --- a/src/std/collections/rbtree.rs +++ b/src/std/collections/rbtree.rs @@ -138,13 +138,6 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for RB RBNode::B(b) => b.points_typed(points), } } - - fn points(&self, points: &mut Vec>>) { - match self { - RBNode::R(r) => r.points(points), - RBNode::B(b) => b.points(points), - } - } } impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for BNode<'a, Ctx, A> { @@ -161,12 +154,6 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for BN self.cr.points_typed(points); self.key.points_typed(points); } - - fn points(&self, points: &mut Vec>>) { - self.cl.points(points); - self.cr.points(points); - self.key.points(points); - } } impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for RNode<'a, Ctx, A> { @@ -183,12 +170,6 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for RN self.cr.points_typed(points); self.key.points_typed(points); } - - fn points(&self, points: &mut Vec>>) { - self.cl.points(points); - self.cr.points(points); - self.key.points(points); - } } impl<'a, Ctx: 'a + Context, F: Factory<'a, Ctx>> Factory<'a, Ctx> for RBFactory { diff --git a/src/std/collections/stack.rs b/src/std/collections/stack.rs index 919ea08..0f2e737 100644 --- a/src/std/collections/stack.rs +++ b/src/std/collections/stack.rs @@ -46,11 +46,6 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> self.rest.points_typed(points); self.element.points_typed(points); } - - fn points(&self, points: &mut Vec>>) { - self.rest.points(points); - self.element.points(points); - } } impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Clone for StackNodeFactory<'a, Ctx, A> { diff --git a/src/core/typeless.rs b/src/std/ctypeless.rs similarity index 93% rename from src/core/typeless.rs rename to src/std/ctypeless.rs index 9ebf535..56c7798 100644 --- a/src/core/typeless.rs +++ b/src/std/ctypeless.rs @@ -1,8 +1,10 @@ -use super::*; +//! Previously part of [`crate::core`]. + +use super::{typeless::*, *}; type TypelessSerialize<'a> = dyn 'a + Fn(&mut dyn Serializer); -/// See [`Mentionable::points`]. +/// See [`Point::typeless`]. pub struct TypelessMentionable<'a, Ctx: 'a + Context> { t_serialize: Box>, t_factory: TypelessFactory<'a, Ctx>, @@ -33,7 +35,7 @@ trait Tut<'a, Ctx: 'a + Context>: 'a + Send + Sync { type TutBox<'a, Ctx> = Box>; -/// See [`Mentionable::points`]/[`TypelessMentionable`]. +/// See [`Point::typeless`]/[`TypelessMentionable`]. pub struct TypelessFactory<'a, Ctx: 'a + Context> { t_deserialize: TdeBox<'a, Ctx>, t_unexpected_tail: TutBox<'a, Ctx>, @@ -61,10 +63,6 @@ impl<'a, Ctx: 'a + Context> Mentionable<'a, Ctx> for TypelessMentionable<'a, Ctx points.take(point) } } - - fn points(&self, points: &mut Vec>>) { - points.extend(self.t_points.iter().map(Clone::clone)); - } } impl<'a, Ctx: 'a + Context> Clone for TypelessFactory<'a, Ctx> { @@ -76,7 +74,7 @@ impl<'a, Ctx: 'a + Context> Clone for TypelessFactory<'a, Ctx> { } } -/// See [`Mentionable::points`]/[`TypelessFactory`]. +/// See [`Point::typeless`]/[`TypelessFactory`]. #[derive(Debug)] pub struct TypelessError<'a>(Box); @@ -178,7 +176,7 @@ trait MentionableExt<'a, Ctx: 'a + Context>: Mentionable<'a, Ctx> { impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> MentionableExt<'a, Ctx> for A { fn points_vec(&self) -> Vec>> { let mut points = Vec::new(); - self.points(&mut points); + self.points_typeless(&mut points); points } } diff --git a/src/std/inlining/static_pair.rs b/src/std/inlining/static_pair.rs index 9592185..384b1c3 100644 --- a/src/std/inlining/static_pair.rs +++ b/src/std/inlining/static_pair.rs @@ -113,12 +113,6 @@ impl<'a, Ctx: 'a + Context, SP: StaticPair<'a, Ctx>> Mentionable<'a, Ctx> for St a.points_typed(points); b.points_typed(points); } - - fn points(&self, points: &mut Vec>>) { - let (a, b) = self.pair.elements(); - a.points(points); - b.points(points); - } } impl<'a, Ctx: 'a + Context, SP: StaticPair<'a, Ctx>> Clone for StaticPairFactory<'a, Ctx, SP> { diff --git a/src/std/nullable.rs b/src/std/nullable.rs index 7ca52d0..3421355 100644 --- a/src/std/nullable.rs +++ b/src/std/nullable.rs @@ -47,13 +47,6 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Nu Nullable::NotNull(point) => points.take(point), } } - - fn points(&self, points: &mut Vec>>) { - match self { - Nullable::Null(_) => {} - Nullable::NotNull(point) => points.push(point.typeless()), - }; - } } impl<'a, Ctx: 'a + Context, F: Factory<'a, Ctx>> Factory<'a, Ctx> for NullableFactory { diff --git a/src/std/point.rs b/src/std/point.rs index 0911079..60d4144 100644 --- a/src/std/point.rs +++ b/src/std/point.rs @@ -26,10 +26,6 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Po fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) { points.take(self) } - - fn points(&self, points: &mut Vec>>) { - points.push(self.typeless()); - } } #[derive(Clone)] diff --git a/src/std/tracing/traceable.rs b/src/std/tracing/traceable.rs index 50909d7..759c02e 100644 --- a/src/std/tracing/traceable.rs +++ b/src/std/tracing/traceable.rs @@ -1,4 +1,4 @@ -use crate::std::cast::*; +use crate::std::{cast::*, ctypeless::*}; use super::*; diff --git a/src/std/typeless.rs b/src/std/typeless.rs index 7e1db8c..deeab07 100644 --- a/src/std/typeless.rs +++ b/src/std/typeless.rs @@ -2,7 +2,7 @@ use std::rc::Rc; use crate::core::*; -use super::*; +use super::{ctypeless::*, *}; struct WrappedOrigin<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> { w_factory: A::Fctr, @@ -89,7 +89,7 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Origin<'a, Ctx> for Wrapped } impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Point<'a, Ctx, A> { - /// Typeless version of the point. Useful for [Mentionable::points] implementaion. + /// Typeless version of the point. pub fn typeless(&self) -> Point<'a, Ctx, TypelessMentionable<'a, Ctx>> { Point { point: self.point, diff --git a/src/testing.rs b/src/testing.rs index 3bb4133..b9178a0 100644 --- a/src/testing.rs +++ b/src/testing.rs @@ -8,6 +8,7 @@ use sha2::{Digest, Sha256}; use crate::core::*; use crate::func::*; use crate::std::cast::*; +use crate::std::ctypeless::*; pub struct NoDiagnostic; diff --git a/src/testing/counted.rs b/src/testing/counted.rs index c0bf40e..64ea2c6 100644 --- a/src/testing/counted.rs +++ b/src/testing/counted.rs @@ -2,6 +2,7 @@ use std::cmp::max; use crate::core::*; use crate::func::*; +use crate::std::ctypeless::*; use super::*;