Skip to content

Commit

Permalink
Add an example to Wrapping's documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiveop committed May 5, 2016
1 parent 7a0ccc4 commit d1c487e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libcore/num/mod.rs
Expand Up @@ -37,6 +37,17 @@ use slice::SliceExt;
/// `wrapping_add`, or through the `Wrapping<T>` type, which says that
/// all standard arithmetic operations on the underlying value are
/// intended to have wrapping semantics.
///
/// # Examples
///
/// ```
/// use std::num::Wrapping;
///
/// let zero = Wrapping(0u32);
/// let one = Wrapping(1u32);
///
/// assert_eq!(std::u32::MAX, (zero - one).0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)]
pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
Expand Down

0 comments on commit d1c487e

Please sign in to comment.