Skip to content

Commit 1a7d3e1

Browse files
committed
Complete PartialOrd's example so it passes make check-docs
1 parent 1b32298 commit 1a7d3e1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/libcore/cmp.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,32 @@ impl PartialOrd for Ordering {
358358
/// If your type is `Ord`, you can implement `partial_cmp()` by using `cmp()`:
359359
///
360360
/// ```
361+
/// use std::cmp::Ordering;
362+
///
363+
/// #[derive(Eq)]
364+
/// struct Person {
365+
/// id: u32,
366+
/// name: String,
367+
/// height: u32,
368+
/// }
369+
///
361370
/// impl PartialOrd for Person {
362371
/// fn partial_cmp(&self, other: &Person) -> Option<Ordering> {
363372
/// Some(self.cmp(other))
364373
/// }
365374
/// }
375+
///
376+
/// impl Ord for Person {
377+
/// fn cmp(&self, other: &Person) -> Ordering {
378+
/// self.height.cmp(&other.height)
379+
/// }
380+
/// }
381+
///
382+
/// impl PartialEq for Person {
383+
/// fn eq(&self, other: &Person) -> bool {
384+
/// self.height == other.height
385+
/// }
386+
/// }
366387
/// ```
367388
///
368389
/// You may also find it useful to use `partial_cmp()` on your type`s fields. Here

0 commit comments

Comments
 (0)