Skip to content

Commit

Permalink
Clean up Arcs impls
Browse files Browse the repository at this point in the history
  • Loading branch information
nxsaken committed Jan 4, 2024
1 parent 8dce9f5 commit 946f96e
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/net/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,21 @@ pub trait Arcs<Net: NetId> {
fn erased() -> Vec<(PlaceId<Net>, usize)>;
}

// single place case
impl<Net, P0, const W0: usize> Arcs<Net> for (P0, W<W0>)
where
Net: NetId,
P0: Place<Net>,
{
fn erased() -> Vec<(PlaceId<Net>, usize)> {
vec![(P0::erased(), W0)]
}
}

macro_rules! impl_arcs {
($(($place:ident, $weight:ident)),*) => {
#[allow(unused_parens)]
impl<Net, $($place, const $weight: usize),*> Arcs<Net> for ($(($place, W<$weight>)),*)
impl<Net, $($place, const $weight: usize),*> Arcs<Net> for ($(($place, W<$weight>),)*)
where
Net: NetId,
$($place: Place<Net>),*
Expand All @@ -90,18 +101,6 @@ macro_rules! impl_arcs {

impl_arcs!();
impl_arcs!((P0, W0));

// 1-tuple case
impl<Net, P0, const W0: usize> Arcs<Net> for ((P0, W<W0>),)
where
Net: NetId,
P0: Place<Net>,
{
fn erased() -> Vec<(PlaceId<Net>, usize)> {
vec![(P0::erased(), W0)]
}
}

impl_arcs!((P0, W0), (P1, W1));
impl_arcs!((P0, W0), (P1, W1), (P2, W2));
impl_arcs!((P0, W0), (P1, W1), (P2, W2), (P3, W3));
Expand Down

0 comments on commit 946f96e

Please sign in to comment.