delete CastResult

This commit is contained in:
AF 2023-06-30 20:35:41 +00:00
parent 671f0df6ae
commit 8c8752c2e4
3 changed files with 5 additions and 8 deletions

View File

@ -148,9 +148,6 @@ where
} }
} }
/// Returned by [`TypelessMentionable::cast`].
pub type CastResult<'a, Ctx, A> = Result<A, ParseErrorA<'a, Ctx, A>>;
impl<'a, Ctx: Context<'a>> TypelessMentionable<'a, Ctx> impl<'a, Ctx: Context<'a>> TypelessMentionable<'a, Ctx>
where where
Ctx::LookupError: From<CastError<'a>>, Ctx::LookupError: From<CastError<'a>>,
@ -159,7 +156,7 @@ where
&self, &self,
factory: A::Fctr, factory: A::Fctr,
map_resolver: impl FnOnce(Rc<dyn Resolver<'a, Ctx>>) -> Rc<dyn Resolver<'a, Ctx>>, map_resolver: impl FnOnce(Rc<dyn Resolver<'a, Ctx>>) -> Rc<dyn Resolver<'a, Ctx>>,
) -> CastResult<'a, Ctx, A> { ) -> ParseResultA<'a, Ctx, A> {
factory.parse_slice( factory.parse_slice(
&self.bytes(), &self.bytes(),
&map_resolver(CastResolver::rc(self.points_vec())), &map_resolver(CastResolver::rc(self.points_vec())),
@ -167,7 +164,7 @@ where
} }
/// Re-parse the object as if it is of a specific type. Has potential to break topology. /// Re-parse the object as if it is of a specific type. Has potential to break topology.
pub fn cast<A: Mentionable<'a, Ctx>>(&self, factory: A::Fctr) -> CastResult<'a, Ctx, A> { pub fn cast<A: Mentionable<'a, Ctx>>(&self, factory: A::Fctr) -> ParseResultA<'a, Ctx, A> {
self.cast_full(factory, identity) self.cast_full(factory, identity)
} }
} }

View File

@ -34,14 +34,14 @@ pub trait Traceable<'a, Ctx: Context<'a, _Tm = TracedInstance>>:
/// ///
/// [^extra]: applying [`Traceable::trace`] multiple times /// [^extra]: applying [`Traceable::trace`] multiple times
/// might affect the trace in undesireable ways /// might affect the trace in undesireable ways
fn trace(self: Rc<Self>) -> CastResult<'a, Ctx, Self>; fn trace(self: Rc<Self>) -> ParseResultA<'a, Ctx, Self>;
} }
impl<'a, Ctx: Context<'a, _Tm = TracedInstance>, A: Mentionable<'a, Ctx>> Traceable<'a, Ctx> for A impl<'a, Ctx: Context<'a, _Tm = TracedInstance>, A: Mentionable<'a, Ctx>> Traceable<'a, Ctx> for A
where where
Ctx::LookupError: From<CastError<'a>>, Ctx::LookupError: From<CastError<'a>>,
{ {
fn trace(self: Rc<Self>) -> CastResult<'a, Ctx, Self> { fn trace(self: Rc<Self>) -> ParseResultA<'a, Ctx, Self> {
let factory = self.factory(); let factory = self.factory();
TypelessMentionable::from_typed(self).cast_full(factory, TracedResolver::wrap) TypelessMentionable::from_typed(self).cast_full(factory, TracedResolver::wrap)
} }

View File

@ -83,7 +83,7 @@ impl<'a> Resolver<'a, TestContextCounted> for CountedResolver<'a> {
} }
pub trait Delayable<'a>: Mentionable<'a, TestContextCounted> + Sized { pub trait Delayable<'a>: Mentionable<'a, TestContextCounted> + Sized {
fn delay(self: Rc<Self>) -> CastResult<'a, TestContextCounted, Self> { fn delay(self: Rc<Self>) -> ParseResultA<'a, TestContextCounted, Self> {
let factory = self.factory(); let factory = self.factory();
TypelessMentionable::from_typed(self).cast_full(factory, CountedResolver::new) TypelessMentionable::from_typed(self).cast_full(factory, CountedResolver::new)
} }