mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
Add an example to Wrapping's documentation.
This commit is contained in:
parent
7a0ccc458f
commit
d1c487e6c7
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user