move points_vec out of Mentionable

This commit is contained in:
AF 2023-05-07 16:54:54 +00:00
parent ff4b4bb5b7
commit 83f9296a4f
2 changed files with 7 additions and 4 deletions

View File

@ -74,7 +74,14 @@ pub trait Mentionable<'a, Ctx: 'a + Context>: 'a + Serializable {
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>);
/// References ([Point]s) to other objects. Typeless.
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);

View File

@ -65,10 +65,6 @@ impl<'a, Ctx: 'a + Context> Mentionable<'a, Ctx> for TypelessMentionable<'a, Ctx
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {
points.extend(self.t_points.iter().map(Clone::clone));
}
fn points_vec(&self) -> Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>> {
self.t_points.clone()
}
}
impl<'a, Ctx: 'a + Context> Clone for TypelessFactory<'a, Ctx> {