From d1c487e6c738ebaee576c03f711ed26a1117d7f1 Mon Sep 17 00:00:00 2001 From: Philipp Matthias Schaefer Date: Thu, 5 May 2016 08:23:24 +0200 Subject: [PATCH] Add an example to Wrapping's documentation. --- src/libcore/num/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 589ac90b308..af4ac482cf7 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -37,6 +37,17 @@ use slice::SliceExt; /// `wrapping_add`, or through the `Wrapping` 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(#[stable(feature = "rust1", since = "1.0.0")] pub T);