Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add doc examples
  • Loading branch information
GuillaumeGomez committed Mar 18, 2016
1 parent b12b4e4 commit 3aac461
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/libcore/cmp.rs
Expand Up @@ -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")]

Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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> {
Expand Down

0 comments on commit 3aac461

Please sign in to comment.