Skip to content

Commit

Permalink
feat: Add PartialEq impls for FuncTypeBase and Cow<FuncTypeBase> (
Browse files Browse the repository at this point in the history
#1762)

Some existing out-of-tree tests are broken by the `Cow` changes. Seems
better to add these than fix the callsites.
  • Loading branch information
doug-q authored Dec 11, 2024
1 parent 5b50d1d commit 66465db
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion hugr-core/src/types/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use itertools::Either;

use std::borrow::Cow;
use std::fmt::{self, Display, Write};

use super::type_param::TypeParam;
Expand All @@ -14,7 +15,7 @@ use crate::extension::{ExtensionRegistry, ExtensionSet, SignatureError};
use crate::{Direction, IncomingPort, OutgoingPort, Port};

#[cfg(test)]
use {crate::proptest::RecursionDepth, ::proptest::prelude::*, proptest_derive::Arbitrary};
use {crate::proptest::RecursionDepth, proptest::prelude::*, proptest_derive::Arbitrary};

#[derive(Clone, Debug, Eq, Hash, serde::Serialize, serde::Deserialize)]
#[cfg_attr(test, derive(Arbitrary), proptest(params = "RecursionDepth"))]
Expand Down Expand Up @@ -319,6 +320,18 @@ impl<RV1: MaybeRV, RV2: MaybeRV> PartialEq<FuncTypeBase<RV1>> for FuncTypeBase<R
}
}

impl<RV1: MaybeRV, RV2: MaybeRV> PartialEq<Cow<'_, FuncTypeBase<RV1>>> for FuncTypeBase<RV2> {
fn eq(&self, other: &Cow<'_, FuncTypeBase<RV1>>) -> bool {
self.eq(other.as_ref())
}
}

impl<RV1: MaybeRV, RV2: MaybeRV> PartialEq<FuncTypeBase<RV1>> for Cow<'_, FuncTypeBase<RV2>> {
fn eq(&self, other: &FuncTypeBase<RV1>) -> bool {
self.as_ref().eq(other)
}
}

#[cfg(test)]
mod test {
use crate::{extension::prelude::usize_t, type_row};
Expand Down

0 comments on commit 66465db

Please sign in to comment.