Skip to content

Commit

Permalink
Complete PartialOrd's example so it passes make check-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed May 23, 2016
1 parent 1b32298 commit 1a7d3e1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/libcore/cmp.rs
Expand Up @@ -358,11 +358,32 @@ impl PartialOrd for Ordering {
/// If your type is `Ord`, you can implement `partial_cmp()` by using `cmp()`:
///
/// ```
/// use std::cmp::Ordering;
///
/// #[derive(Eq)]
/// struct Person {
/// id: u32,
/// name: String,
/// height: u32,
/// }
///
/// impl PartialOrd for Person {
/// fn partial_cmp(&self, other: &Person) -> Option<Ordering> {
/// Some(self.cmp(other))
/// }
/// }
///
/// impl Ord for Person {
/// fn cmp(&self, other: &Person) -> Ordering {
/// self.height.cmp(&other.height)
/// }
/// }
///
/// impl PartialEq for Person {
/// fn eq(&self, other: &Person) -> bool {
/// self.height == other.height
/// }
/// }
/// ```
///
/// You may also find it useful to use `partial_cmp()` on your type`s fields. Here
Expand Down

0 comments on commit 1a7d3e1

Please sign in to comment.