Skip to content

Commit 147862d

Browse files
Merge pull request #326 from google:use-description-for-structured-output
PiperOrigin-RevId: 595943355
2 parents 41127ca + 3edb5e6 commit 147862d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1853
-1032
lines changed

googletest/crate_docs.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ a struct holding the matcher's data and have it implement the trait
209209
[`Matcher`]:
210210

211211
```no_run
212-
use googletest::matcher::{Matcher, MatcherResult};
212+
use googletest::{description::Description, matcher::{Matcher, MatcherResult}};
213213
use std::fmt::Debug;
214214
215215
struct MyEqMatcher<T> {
@@ -227,13 +227,13 @@ impl<T: PartialEq + Debug> Matcher for MyEqMatcher<T> {
227227
}
228228
}
229229
230-
fn describe(&self, matcher_result: MatcherResult) -> String {
230+
fn describe(&self, matcher_result: MatcherResult) -> Description {
231231
match matcher_result {
232232
MatcherResult::Match => {
233-
format!("is equal to {:?} the way I define it", self.expected)
233+
format!("is equal to {:?} the way I define it", self.expected).into()
234234
}
235235
MatcherResult::NoMatch => {
236-
format!("isn't equal to {:?} the way I define it", self.expected)
236+
format!("isn't equal to {:?} the way I define it", self.expected).into()
237237
}
238238
}
239239
}
@@ -243,7 +243,7 @@ impl<T: PartialEq + Debug> Matcher for MyEqMatcher<T> {
243243
It is recommended to expose a function which constructs the matcher:
244244

245245
```no_run
246-
# use googletest::matcher::{Matcher, MatcherResult};
246+
# use googletest::{description::Description, matcher::{Matcher, MatcherResult}};
247247
# use std::fmt::Debug;
248248
#
249249
# struct MyEqMatcher<T> {
@@ -261,13 +261,13 @@ impl<T: PartialEq + Debug> Matcher for MyEqMatcher<T> {
261261
# }
262262
# }
263263
#
264-
# fn describe(&self, matcher_result: MatcherResult) -> String {
264+
# fn describe(&self, matcher_result: MatcherResult) -> Description {
265265
# match matcher_result {
266266
# MatcherResult::Match => {
267-
# format!("is equal to {:?} the way I define it", self.expected)
267+
# format!("is equal to {:?} the way I define it", self.expected).into()
268268
# }
269269
# MatcherResult::NoMatch => {
270-
# format!("isn't equal to {:?} the way I define it", self.expected)
270+
# format!("isn't equal to {:?} the way I define it", self.expected).into()
271271
# }
272272
# }
273273
# }
@@ -282,7 +282,7 @@ impl<T: PartialEq + Debug> Matcher for MyEqMatcher<T> {
282282

283283
```
284284
# use googletest::prelude::*;
285-
# use googletest::matcher::{Matcher, MatcherResult};
285+
# use googletest::{description::Description, matcher::{Matcher, MatcherResult}};
286286
# use std::fmt::Debug;
287287
#
288288
# struct MyEqMatcher<T> {
@@ -300,13 +300,13 @@ impl<T: PartialEq + Debug> Matcher for MyEqMatcher<T> {
300300
# }
301301
# }
302302
#
303-
# fn describe(&self, matcher_result: MatcherResult) -> String {
303+
# fn describe(&self, matcher_result: MatcherResult) -> Description {
304304
# match matcher_result {
305305
# MatcherResult::Match => {
306-
# format!("is equal to {:?} the way I define it", self.expected)
306+
# format!("is equal to {:?} the way I define it", self.expected).into()
307307
# }
308308
# MatcherResult::NoMatch => {
309-
# format!("isn't equal to {:?} the way I define it", self.expected)
309+
# format!("isn't equal to {:?} the way I define it", self.expected).into()
310310
# }
311311
# }
312312
# }

0 commit comments

Comments
 (0)