Skip to content

Commit 8d70e80

Browse files
gribozavrcopybara-github
authored andcommitted
Remove an unnecessary type parameter ActualT from ConjunctionMatcher and DisjunctionMatcher
We already have this type, it is available as both `M1::ActualT` and `M2::ActualT`. PiperOrigin-RevId: 532467374
1 parent d6f4cc5 commit 8d70e80

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

googletest/src/matcher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub trait Matcher {
159159
fn and<Right: Matcher<ActualT = Self::ActualT>>(
160160
self,
161161
right: Right,
162-
) -> ConjunctionMatcher<Self::ActualT, Self, Right>
162+
) -> ConjunctionMatcher<Self, Right>
163163
where
164164
Self: Sized,
165165
{
@@ -189,7 +189,7 @@ pub trait Matcher {
189189
fn or<Right: Matcher<ActualT = Self::ActualT>>(
190190
self,
191191
right: Right,
192-
) -> DisjunctionMatcher<Self::ActualT, Self, Right>
192+
) -> DisjunctionMatcher<Self, Right>
193193
where
194194
Self: Sized,
195195
{

googletest/src/matchers/conjunction_matcher.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,37 @@
1313
// limitations under the License.
1414

1515
use crate::matcher::{Matcher, MatcherResult};
16-
use std::{fmt::Debug, marker::PhantomData};
16+
use std::fmt::Debug;
1717

1818
/// Matcher created by [`Matcher::and`].
1919
///
2020
/// **For internal use only. API stablility is not guaranteed!**
2121
#[doc(hidden)]
22-
pub struct ConjunctionMatcher<T: ?Sized, M1, M2> {
22+
pub struct ConjunctionMatcher<M1, M2> {
2323
m1: M1,
2424
m2: M2,
25-
phantom: PhantomData<T>,
2625
}
2726

28-
impl<T: ?Sized, M1, M2> ConjunctionMatcher<T, M1, M2> {
27+
impl<M1, M2> ConjunctionMatcher<M1, M2> {
2928
pub(crate) fn new(m1: M1, m2: M2) -> Self {
30-
Self { m1, m2, phantom: Default::default() }
29+
Self { m1, m2 }
3130
}
3231
}
3332

34-
impl<T: Debug + ?Sized, M1: Matcher<ActualT = T>, M2: Matcher<ActualT = T>> Matcher
35-
for ConjunctionMatcher<T, M1, M2>
33+
impl<M1: Matcher, M2: Matcher<ActualT = M1::ActualT>> Matcher for ConjunctionMatcher<M1, M2>
34+
where
35+
M1::ActualT: Debug,
3636
{
37-
type ActualT = T;
37+
type ActualT = M1::ActualT;
3838

39-
fn matches(&self, actual: &T) -> MatcherResult {
39+
fn matches(&self, actual: &M1::ActualT) -> MatcherResult {
4040
match (self.m1.matches(actual), self.m2.matches(actual)) {
4141
(MatcherResult::Matches, MatcherResult::Matches) => MatcherResult::Matches,
4242
_ => MatcherResult::DoesNotMatch,
4343
}
4444
}
4545

46-
fn explain_match(&self, actual: &T) -> String {
46+
fn explain_match(&self, actual: &M1::ActualT) -> String {
4747
match (self.m1.matches(actual), self.m2.matches(actual)) {
4848
(MatcherResult::Matches, MatcherResult::Matches) => {
4949
format!(

googletest/src/matchers/disjunction_matcher.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,30 @@
1313
// limitations under the License.
1414

1515
use crate::matcher::{Matcher, MatcherResult};
16-
use std::{fmt::Debug, marker::PhantomData};
16+
use std::fmt::Debug;
1717

1818
/// Matcher created by [`Matcher::or`].
1919
///
2020
/// **For internal use only. API stablility is not guaranteed!**
2121
#[doc(hidden)]
22-
pub struct DisjunctionMatcher<T: ?Sized, M1, M2> {
22+
pub struct DisjunctionMatcher<M1, M2> {
2323
m1: M1,
2424
m2: M2,
25-
phantom: PhantomData<T>,
2625
}
2726

28-
impl<T: ?Sized, M1, M2> DisjunctionMatcher<T, M1, M2> {
27+
impl<M1, M2> DisjunctionMatcher<M1, M2> {
2928
pub(crate) fn new(m1: M1, m2: M2) -> Self {
30-
Self { m1, m2, phantom: Default::default() }
29+
Self { m1, m2 }
3130
}
3231
}
3332

34-
impl<T: Debug + ?Sized, M1: Matcher<ActualT = T>, M2: Matcher<ActualT = T>> Matcher
35-
for DisjunctionMatcher<T, M1, M2>
33+
impl<M1: Matcher, M2: Matcher<ActualT = M1::ActualT>> Matcher for DisjunctionMatcher<M1, M2>
34+
where
35+
M1::ActualT: Debug,
3636
{
37-
type ActualT = T;
37+
type ActualT = M1::ActualT;
3838

39-
fn matches(&self, actual: &T) -> MatcherResult {
39+
fn matches(&self, actual: &M1::ActualT) -> MatcherResult {
4040
match (self.m1.matches(actual), self.m2.matches(actual)) {
4141
(MatcherResult::DoesNotMatch, MatcherResult::DoesNotMatch) => {
4242
MatcherResult::DoesNotMatch
@@ -45,7 +45,7 @@ impl<T: Debug + ?Sized, M1: Matcher<ActualT = T>, M2: Matcher<ActualT = T>> Matc
4545
}
4646
}
4747

48-
fn explain_match(&self, actual: &T) -> String {
48+
fn explain_match(&self, actual: &M1::ActualT) -> String {
4949
format!("{} and\n {}", self.m1.explain_match(actual), self.m2.explain_match(actual))
5050
}
5151

0 commit comments

Comments
 (0)