diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-03-14 16:43:55 +0100 |
|---|---|---|
| committer | ggomez <guillaume1.gomez@gmail.com> | 2016-03-18 15:47:33 +0100 |
| commit | 3aac461d4053e8f8479d72a3a4c2f26a1b13a5aa (patch) | |
| tree | ffbceb35ba31eb6d2d37a42ae6c9095f479f7e9e | |
| parent | b12b4e4e3266644d519647afc2943cefa2026e07 (diff) | |
| download | rust-3aac461d4053e8f8479d72a3a4c2f26a1b13a5aa.tar.gz rust-3aac461d4053e8f8479d72a3a4c2f26a1b13a5aa.zip | |
Add doc examples
| -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> { |
