mirror of https://codeberg.org/topola/topola.git
feat(geometry/geometry): Add convenience GetPetgraphIndex impls
This commit is contained in:
parent
f9b1cc2cbf
commit
2394fa6256
|
|
@ -73,6 +73,15 @@ pub enum GenericNode<P, C> {
|
|||
Compound(C),
|
||||
}
|
||||
|
||||
impl<P: GetPetgraphIndex, C: GetPetgraphIndex> GetPetgraphIndex for GenericNode<P, C> {
|
||||
fn petgraph_index(&self) -> NodeIndex<usize> {
|
||||
match self {
|
||||
Self::Primitive(x) => x.petgraph_index(),
|
||||
Self::Compound(x) => x.petgraph_index(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AccessDotWeight: GetSetPos + GetWidth + Copy {}
|
||||
impl<T: GetSetPos + GetWidth + Copy> AccessDotWeight for T {}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,13 @@ pub trait GetPetgraphIndex {
|
|||
fn petgraph_index(&self) -> NodeIndex<usize>;
|
||||
}
|
||||
|
||||
impl GetPetgraphIndex for NodeIndex<usize> {
|
||||
#[inline(always)]
|
||||
fn petgraph_index(&self) -> NodeIndex<usize> {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
// unfortunately, as we don't want any restrictions on `W`,
|
||||
// we have to implement many traits ourselves, instead of using derive macros.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
|
|
@ -40,7 +47,7 @@ impl<W> GenericIndex<W> {
|
|||
}
|
||||
|
||||
impl<W> core::clone::Clone for GenericIndex<W> {
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue