diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2016-03-21 11:46:52 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2016-03-21 11:46:52 -0400 |
| commit | 4ed70c2bc86673d2f0f5227efc03a5af0111cb4c (patch) | |
| tree | f95576ba8a9e85260fda0f2121ff0d94b8c9eeec | |
| parent | 690f160f8f64df041133bcba58416435826d3e73 (diff) | |
| parent | 3aac461d4053e8f8479d72a3a4c2f26a1b13a5aa (diff) | |
| download | rust-4ed70c2bc86673d2f0f5227efc03a5af0111cb4c.tar.gz rust-4ed70c2bc86673d2f0f5227efc03a5af0111cb4c.zip | |
Rollup merge of #32322 - GuillaumeGomez:cmp_doc, r=steveklabnik
Add doc examples Fixes #29347 r? @steveklabnik
| -rw-r--r-- | src/libcore/cmp.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 042cbea64bd..49aa0238a99 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -14,6 +14,21 @@ //! by the compiler to implement comparison operators. Rust programs may //! implement `PartialOrd` to overload the `<`, `<=`, `>`, and `>=` operators, //! and may implement `PartialEq` to overload the `==` and `!=` operators. +//! +//! # Examples +//! +//! ``` +//! let x: u32 = 0; +//! let y: u32 = 1; +//! +//! // these two lines are equivalent +//! assert_eq!(x < y, true); +//! assert_eq!(x.lt(&y), true); +//! +//! // these two lines are also equivalent +//! assert_eq!(x == y, false); +//! assert_eq!(x.eq(&y), false); +//! ``` #![stable(feature = "rust1", since = "1.0.0")] @@ -44,6 +59,16 @@ use option::Option::{self, Some}; /// only if `a != b`. /// /// This trait can be used with `#[derive]`. +/// +/// # Examples +/// +/// ``` +/// let x: u32 = 0; +/// let y: u32 = 1; +/// +/// assert_eq!(x == y, false); +/// assert_eq!(x.eq(&y), false); +/// ``` #[lang = "eq"] #[stable(feature = "rust1", since = "1.0.0")] pub trait PartialEq<Rhs: ?Sized = Self> { @@ -226,6 +251,16 @@ impl PartialOrd for Ordering { /// /// This trait can be used with `#[derive]`. When `derive`d, it will produce an ordering /// based on the top-to-bottom declaration order of the struct's members. +/// +/// # Examples +/// +/// ``` +/// let x : u32 = 0; +/// let y : u32 = 1; +/// +/// assert_eq!(x < y, true); +/// assert_eq!(x.lt(&y), true); +/// ``` #[lang = "ord"] #[stable(feature = "rust1", since = "1.0.0")] pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> { |
