mirror of https://codeberg.org/topola/topola.git
primitive: create `GetWraparound` trait to get the wraparound
Wraparound is either the outer bend or the first rail bend. We need this trait because some routines can wrap around both fixed and loose primitives.
This commit is contained in:
parent
ef593aca78
commit
73736fef50
|
|
@ -50,6 +50,10 @@ pub trait GetOtherEnd<F: GetNodeIndex, T: GetNodeIndex + Into<F>>: GetEnds<F, T>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait GetWraparound: GetLayout + GetNodeIndex {
|
||||||
|
fn wraparound(&self) -> Option<LooseBendIndex>;
|
||||||
|
}
|
||||||
|
|
||||||
pub trait GetFirstRail: GetLayout + GetNodeIndex {
|
pub trait GetFirstRail: GetLayout + GetNodeIndex {
|
||||||
fn first_rail(&self) -> Option<LooseBendIndex> {
|
fn first_rail(&self) -> Option<LooseBendIndex> {
|
||||||
self.layout()
|
self.layout()
|
||||||
|
|
@ -287,6 +291,12 @@ impl<'a> MakeShape for FixedDot<'a> {
|
||||||
|
|
||||||
impl<'a> GetFirstRail for FixedDot<'a> {}
|
impl<'a> GetFirstRail for FixedDot<'a> {}
|
||||||
|
|
||||||
|
impl<'a> GetWraparound for FixedDot<'a> {
|
||||||
|
fn wraparound(&self) -> Option<LooseBendIndex> {
|
||||||
|
self.first_rail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type LooseDot<'a> = GenericPrimitive<'a, LooseDotWeight>;
|
pub type LooseDot<'a> = GenericPrimitive<'a, LooseDotWeight>;
|
||||||
impl_loose_primitive!(LooseDot, LooseDotWeight);
|
impl_loose_primitive!(LooseDot, LooseDotWeight);
|
||||||
|
|
||||||
|
|
@ -467,6 +477,11 @@ impl<'a> GetEnds<FixedDotIndex, FixedDotIndex> for FixedBend<'a> {
|
||||||
|
|
||||||
impl<'a> GetOtherEnd<FixedDotIndex, FixedDotIndex> for FixedBend<'a> {}
|
impl<'a> GetOtherEnd<FixedDotIndex, FixedDotIndex> for FixedBend<'a> {}
|
||||||
impl<'a> GetFirstRail for FixedBend<'a> {}
|
impl<'a> GetFirstRail for FixedBend<'a> {}
|
||||||
|
impl<'a> GetWraparound for FixedBend<'a> {
|
||||||
|
fn wraparound(&self) -> Option<LooseBendIndex> {
|
||||||
|
self.first_rail()
|
||||||
|
}
|
||||||
|
}
|
||||||
impl<'a> GetCore for FixedBend<'a> {} // TODO: Fixed bends don't have cores actually.
|
impl<'a> GetCore for FixedBend<'a> {} // TODO: Fixed bends don't have cores actually.
|
||||||
//impl<'a> GetInnerOuter for FixedBend<'a> {}
|
//impl<'a> GetInnerOuter for FixedBend<'a> {}
|
||||||
|
|
||||||
|
|
@ -537,5 +552,10 @@ impl<'a> GetEnds<LooseDotIndex, LooseDotIndex> for LooseBend<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> GetOtherEnd<LooseDotIndex, LooseDotIndex> for LooseBend<'a> {}
|
impl<'a> GetOtherEnd<LooseDotIndex, LooseDotIndex> for LooseBend<'a> {}
|
||||||
|
impl<'a> GetWraparound for LooseBend<'a> {
|
||||||
|
fn wraparound(&self) -> Option<LooseBendIndex> {
|
||||||
|
self.outer()
|
||||||
|
}
|
||||||
|
}
|
||||||
impl<'a> GetCore for LooseBend<'a> {}
|
impl<'a> GetCore for LooseBend<'a> {}
|
||||||
impl<'a> GetInnerOuter for LooseBend<'a> {}
|
impl<'a> GetInnerOuter for LooseBend<'a> {}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue