move MentionableExt to core::typeless

This commit is contained in:
AF 2023-05-07 16:56:42 +00:00
parent 83f9296a4f
commit 43ae010a93
2 changed files with 13 additions and 13 deletions

View File

@ -76,19 +76,6 @@ pub trait Mentionable<'a, Ctx: 'a + Context>: 'a + Serializable {
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>); fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>);
} }
pub trait MentionableExt<'a, Ctx: 'a + Context>: Mentionable<'a, Ctx> {
/// [Vec] of [Point]s as used by [`Mentionable::topology`].
fn points_vec(&self) -> Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>;
}
impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> MentionableExt<'a, Ctx> for A {
fn points_vec(&self) -> Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>> {
let mut points = Vec::new();
self.points(&mut points);
points
}
}
/// Shorthand for the type of vaalues returned by [`Factory::deserialize`]. /// Shorthand for the type of vaalues returned by [`Factory::deserialize`].
pub type ParseResult<'a, Ctx, F> = pub type ParseResult<'a, Ctx, F> =
Result<<F as Factory<'a, Ctx>>::Mtbl, <F as Factory<'a, Ctx>>::ParseError>; Result<<F as Factory<'a, Ctx>>::Mtbl, <F as Factory<'a, Ctx>>::ParseError>;

View File

@ -169,3 +169,16 @@ impl<'a> TypelessError<'a> {
TypelessError(Box::new(error)) TypelessError(Box::new(error))
} }
} }
pub trait MentionableExt<'a, Ctx: 'a + Context>: Mentionable<'a, Ctx> {
/// [Vec] of [Point]s as used by [`Mentionable::topology`].
fn points_vec(&self) -> Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>;
}
impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> MentionableExt<'a, Ctx> for A {
fn points_vec(&self) -> Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>> {
let mut points = Vec::new();
self.points(&mut points);
points
}
}