Skip to content

Commit 9c5564a

Browse files
bjacotgcopybara-github
authored andcommitted
Copybara import of the project:
-- 4b67c374d49b00860a8f285aae2e064cc58a0dc7 by Bastien Jacot-Guillarmod <[email protected]>: Make `ActualT` in `Matcher` a generic type parameter. COPYBARA_INTEGRATE_REVIEW=google/googletest-rust#349 from google:generic_parameter 4b67c374d49b00860a8f285aae2e064cc58a0dc7 FUTURE_COPYBARA_INTEGRATE_REVIEW=google/googletest-rust#349 from google:generic_parameter 4b67c374d49b00860a8f285aae2e064cc58a0dc7 PiperOrigin-RevId: 607661947
1 parent 7949a62 commit 9c5564a

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

rust/test/shared/matchers.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@ use googletest::description::Description;
22
use googletest::matcher::MatcherResult;
33
use googletest::prelude::*;
44
use protobuf::{AbsentField, Optional, PresentField, ProxiedWithPresence};
5-
use std::marker::PhantomData;
65

76
/// ===============================
87
/// IS_UNSET
98
/// ===============================
109
pub fn is_unset<'a, T: std::fmt::Debug + ProxiedWithPresence + ?Sized + 'a>()
11-
-> impl Matcher<ActualT = Optional<PresentField<'a, T>, AbsentField<'a, T>>> {
12-
UnsetMatcher::<T> { _phantom: PhantomData }
10+
-> impl Matcher<Optional<PresentField<'a, T>, AbsentField<'a, T>>> {
11+
UnsetMatcher
1312
}
1413

15-
struct UnsetMatcher<'a, T: ProxiedWithPresence + ?Sized> {
16-
_phantom: PhantomData<PresentField<'a, T>>,
17-
}
18-
19-
impl<'a, T: std::fmt::Debug + ProxiedWithPresence + ?Sized> Matcher for UnsetMatcher<'a, T> {
20-
type ActualT = Optional<PresentField<'a, T>, AbsentField<'a, T>>;
14+
#[derive(MatcherExt)]
15+
struct UnsetMatcher;
2116

22-
fn matches(&self, actual: &Self::ActualT) -> MatcherResult {
17+
impl<'a, T: std::fmt::Debug + ProxiedWithPresence + ?Sized>
18+
Matcher<Optional<PresentField<'a, T>, AbsentField<'a, T>>> for UnsetMatcher
19+
{
20+
fn matches(&self, actual: &Optional<PresentField<'a, T>, AbsentField<'a, T>>) -> MatcherResult {
2321
actual.is_unset().into()
2422
}
2523

@@ -35,18 +33,17 @@ impl<'a, T: std::fmt::Debug + ProxiedWithPresence + ?Sized> Matcher for UnsetMat
3533
/// IS_SET
3634
/// ===============================
3735
pub fn is_set<'a, T: std::fmt::Debug + ProxiedWithPresence + ?Sized + 'a>()
38-
-> impl Matcher<ActualT = Optional<PresentField<'a, T>, AbsentField<'a, T>>> {
39-
SetMatcher::<T> { _phantom: PhantomData }
40-
}
41-
42-
struct SetMatcher<'a, T: ProxiedWithPresence + ?Sized> {
43-
_phantom: PhantomData<PresentField<'a, T>>,
36+
-> impl Matcher<Optional<PresentField<'a, T>, AbsentField<'a, T>>> {
37+
SetMatcher
4438
}
4539

46-
impl<'a, T: std::fmt::Debug + ProxiedWithPresence + ?Sized> Matcher for SetMatcher<'a, T> {
47-
type ActualT = Optional<PresentField<'a, T>, AbsentField<'a, T>>;
40+
#[derive(MatcherExt)]
41+
struct SetMatcher;
4842

49-
fn matches(&self, actual: &Self::ActualT) -> MatcherResult {
43+
impl<'a, T: std::fmt::Debug + ProxiedWithPresence + ?Sized>
44+
Matcher<Optional<PresentField<'a, T>, AbsentField<'a, T>>> for SetMatcher
45+
{
46+
fn matches(&self, actual: &Optional<PresentField<'a, T>, AbsentField<'a, T>>) -> MatcherResult {
5047
actual.is_set().into()
5148
}
5249

0 commit comments

Comments
 (0)