From 6d072473ab752d7be633acf8687d447aa24167fd Mon Sep 17 00:00:00 2001 From: Bradford Hovinen Date: Fri, 28 Jul 2023 10:02:06 +0200 Subject: [PATCH] Reduce the visibility of most submodules of `matchers`. This reduces the number of public paths to each of the matcher functions. The functions are now visible only from the `matchers` module, and submodules containing those functions no longer appear in published documentation. Submodules containing macros which construct matchers remain public, since downstream crates still depend on these. This also reduces the visibility of some matcher structs which do not need to be public. Their constructor functions return `impl Matcher` and they provide no additional methods. --- googletest/src/matchers/ge_matcher.rs | 2 +- googletest/src/matchers/le_matcher.rs | 2 +- googletest/src/matchers/lt_matcher.rs | 2 +- googletest/src/matchers/mod.rs | 72 ++++++++++++++------------- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/googletest/src/matchers/ge_matcher.rs b/googletest/src/matchers/ge_matcher.rs index 95bea914..33e847ec 100644 --- a/googletest/src/matchers/ge_matcher.rs +++ b/googletest/src/matchers/ge_matcher.rs @@ -77,7 +77,7 @@ pub fn ge, ExpectedT: Debug>( GeMatcher:: { expected, phantom: Default::default() } } -pub struct GeMatcher { +struct GeMatcher { expected: ExpectedT, phantom: PhantomData, } diff --git a/googletest/src/matchers/le_matcher.rs b/googletest/src/matchers/le_matcher.rs index 05156b1e..6e7a16f7 100644 --- a/googletest/src/matchers/le_matcher.rs +++ b/googletest/src/matchers/le_matcher.rs @@ -77,7 +77,7 @@ pub fn le, ExpectedT: Debug>( LeMatcher:: { expected, phantom: Default::default() } } -pub struct LeMatcher { +struct LeMatcher { expected: ExpectedT, phantom: PhantomData, } diff --git a/googletest/src/matchers/lt_matcher.rs b/googletest/src/matchers/lt_matcher.rs index 3e3ba26c..96df00c3 100644 --- a/googletest/src/matchers/lt_matcher.rs +++ b/googletest/src/matchers/lt_matcher.rs @@ -77,7 +77,7 @@ pub fn lt, ExpectedT: Debug>( LtMatcher:: { expected, phantom: Default::default() } } -pub struct LtMatcher { +struct LtMatcher { expected: ExpectedT, phantom: PhantomData, } diff --git a/googletest/src/matchers/mod.rs b/googletest/src/matchers/mod.rs index 60b29594..f8aef109 100644 --- a/googletest/src/matchers/mod.rs +++ b/googletest/src/matchers/mod.rs @@ -16,56 +16,56 @@ pub mod all_matcher; pub mod any_matcher; -pub mod anything_matcher; -pub mod char_count_matcher; +mod anything_matcher; +mod char_count_matcher; pub mod conjunction_matcher; -pub mod container_eq_matcher; -pub mod contains_matcher; -pub mod contains_regex_matcher; +mod container_eq_matcher; +mod contains_matcher; +mod contains_regex_matcher; pub mod disjunction_matcher; -pub mod display_matcher; -pub mod each_matcher; +mod display_matcher; +mod each_matcher; pub mod elements_are_matcher; -pub mod empty_matcher; -pub mod eq_deref_of_matcher; -pub mod eq_matcher; -pub mod err_matcher; +mod empty_matcher; +mod eq_deref_of_matcher; +mod eq_matcher; +mod err_matcher; pub mod field_matcher; -pub mod ge_matcher; -pub mod gt_matcher; -pub mod has_entry_matcher; +mod ge_matcher; +mod gt_matcher; +mod has_entry_matcher; pub mod is_matcher; -pub mod is_nan_matcher; -pub mod le_matcher; -pub mod len_matcher; -pub mod lt_matcher; -pub mod matches_pattern; -pub mod matches_regex_matcher; -pub mod near_matcher; -pub mod none_matcher; -pub mod not_matcher; -pub mod ok_matcher; -pub mod points_to_matcher; +mod is_nan_matcher; +mod le_matcher; +mod len_matcher; +mod lt_matcher; +mod matches_pattern; +mod matches_regex_matcher; +mod near_matcher; +mod none_matcher; +mod not_matcher; +mod ok_matcher; +mod points_to_matcher; pub mod pointwise_matcher; -pub mod predicate_matcher; +mod predicate_matcher; pub mod property_matcher; -pub mod some_matcher; -pub mod str_matcher; -pub mod subset_of_matcher; -pub mod superset_of_matcher; -pub mod tuple_matcher; +mod some_matcher; +mod str_matcher; +mod subset_of_matcher; +mod superset_of_matcher; +mod tuple_matcher; pub mod unordered_elements_are_matcher; pub use anything_matcher::anything; pub use char_count_matcher::char_count; pub use container_eq_matcher::container_eq; -pub use contains_matcher::contains; +pub use contains_matcher::{contains, ContainsMatcher}; pub use contains_regex_matcher::contains_regex; pub use display_matcher::displays_as; pub use each_matcher::each; pub use empty_matcher::empty; pub use eq_deref_of_matcher::eq_deref_of; -pub use eq_matcher::eq; +pub use eq_matcher::{eq, EqMatcher}; pub use err_matcher::err; pub use ge_matcher::ge; pub use gt_matcher::gt; @@ -75,13 +75,15 @@ pub use le_matcher::le; pub use len_matcher::len; pub use lt_matcher::lt; pub use matches_regex_matcher::matches_regex; -pub use near_matcher::{approx_eq, near}; +pub use near_matcher::{approx_eq, near, NearMatcher}; pub use none_matcher::none; pub use not_matcher::not; pub use ok_matcher::ok; pub use points_to_matcher::points_to; pub use predicate_matcher::{predicate, PredicateMatcher}; pub use some_matcher::some; -pub use str_matcher::{contains_substring, ends_with, starts_with, StrMatcherConfigurator}; +pub use str_matcher::{ + contains_substring, ends_with, starts_with, StrMatcher, StrMatcherConfigurator, +}; pub use subset_of_matcher::subset_of; pub use superset_of_matcher::superset_of;