Skip to content

Commit

Permalink
fixup! eq_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel committed Jun 28, 2024
1 parent 301545f commit 1c076be
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions variadics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl VariadicExt for () {
}
}

/// A variadic where each item is a shared reference `&val`.
/// A variadic where each item is a shared reference `&item`.
///
/// This is a sealed trait.
#[sealed]
Expand All @@ -288,7 +288,7 @@ impl RefVariadic for () {
type UnRef = ();
}

/// A variadic where each item is an exclusive reference `&mut val`.
/// A variadic where each item is an exclusive reference `&mut item`.
///
/// This is a sealed trait.
#[sealed]
Expand Down Expand Up @@ -348,14 +348,12 @@ impl CloneRefVariadic for () {

/// A variadic where all item implement `PartialEq`.
#[sealed]
pub trait PartialEqVariadic: Variadic {
pub trait PartialEqVariadic: VariadicExt {
/// `PartialEq` between a referenced variadic and a variadic of references, of the same types.
fn eq(&self, other: &Self) -> bool;

/// `PartialEq` for the `AsRefVar` version op `Self`.
fn eq_ref<'a>(this: Self::AsRefVar<'a>, other: Self::AsRefVar<'a>) -> bool
where
Self: VariadicExt;
fn eq_ref<'a>(this: Self::AsRefVar<'a>, other: Self::AsRefVar<'a>) -> bool;
}
#[sealed]
impl<Item, Rest> PartialEqVariadic for (Item, Rest)
Expand All @@ -372,13 +370,10 @@ where
fn eq_ref<'a>(
this: <Self as VariadicExt>::AsRefVar<'a>,
other: <Self as VariadicExt>::AsRefVar<'a>,
) -> bool
where
Self: VariadicExt,
{
) -> bool {
let var_args!(item_self, ...rest_self) = this;
let var_args!(item_other, ...rest_other) = other;
item_self == item_other && rest_self.eq(rest_other)
item_self == item_other && Rest::eq_ref(rest_self, rest_other)
}
}
#[sealed]
Expand All @@ -390,10 +385,7 @@ impl PartialEqVariadic for () {
fn eq_ref<'a>(
_this: <Self as VariadicExt>::AsRefVar<'a>,
_other: <Self as VariadicExt>::AsRefVar<'a>,
) -> bool
where
Self: VariadicExt,
{
) -> bool {
true
}
}
Expand Down

0 comments on commit 1c076be

Please sign in to comment.