mirror of https://codeberg.org/topola/topola.git
drawing: obtain `HeadRef` via new trait for abstract reference objects
This commit is contained in:
parent
0552dd3f33
commit
57c970e22e
|
|
@ -5,3 +5,5 @@ pub enum BandFirstSegIndex {
|
|||
Straight(LoneLooseSegIndex),
|
||||
Bended(SeqLooseSegIndex),
|
||||
}
|
||||
|
||||
pub struct BandRef {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use enum_dispatch::enum_dispatch;
|
||||
|
||||
use crate::geometry::shape::MeasureLength;
|
||||
use crate::{geometry::shape::MeasureLength, graph::MakeRef};
|
||||
|
||||
use super::{
|
||||
cane::Cane,
|
||||
|
|
@ -22,11 +22,8 @@ pub enum Head {
|
|||
Cane(CaneHead),
|
||||
}
|
||||
|
||||
impl Head {
|
||||
pub fn ref_<'a, CW: Copy, R: AccessRules>(
|
||||
&self,
|
||||
drawing: &'a Drawing<CW, R>,
|
||||
) -> HeadRef<'a, CW, R> {
|
||||
impl<'a, CW: Copy, R: AccessRules> MakeRef<'a, HeadRef<'a, CW, R>, Drawing<CW, R>> for Head {
|
||||
fn ref_(&self, drawing: &'a Drawing<CW, R>) -> HeadRef<'a, CW, R> {
|
||||
HeadRef::new(*self, drawing)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ use std::{
|
|||
use enum_dispatch::enum_dispatch;
|
||||
use petgraph::stable_graph::NodeIndex;
|
||||
|
||||
// Due to apparent limitations of enum_dispatch we're forced to import some types backwards.
|
||||
pub trait MakeRef<'a, R: 'a, C> {
|
||||
fn ref_(&self, context: &'a C) -> R;
|
||||
}
|
||||
|
||||
#[enum_dispatch]
|
||||
pub trait GetPetgraphIndex {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use crate::{
|
|||
primitive::{AccessPrimitiveShape, PrimitiveShape},
|
||||
shape::{AccessShape, MeasureLength},
|
||||
},
|
||||
graph::GetPetgraphIndex,
|
||||
graph::{GetPetgraphIndex, MakeRef},
|
||||
layout::Layout,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue