Skip to content

Commit ff86c84

Browse files
committed
---
yaml --- r: 193979 b: refs/heads/beta c: 4294327 h: refs/heads/master i: 193977: 28a57bd 193975: 1b454ed v: v3
1 parent 1c5c1d4 commit ff86c84

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: 97f03e7ad91cec9715fefbc8112519bd7c01e756
34+
refs/heads/beta: 4294327886ed7c1a21148f86941418a8a5950381
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: de8a23bbc3a7b9cbd7574b5b91a34af59bf030e6

branches/beta/src/libcore/num/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ pub trait Int
345345

346346
/// Saturating integer addition. Computes `self + other`, saturating at
347347
/// the numeric bounds instead of overflowing.
348+
///
349+
/// # Examples
350+
///
351+
/// ```
352+
/// use std::num::Int;
353+
///
354+
/// assert_eq!(5u16.saturating_add(65534), 65535);
355+
/// assert_eq!((-5i16).saturating_add(-32767), -32768);
356+
/// assert_eq!(100u32.saturating_add(4294967294), 4294967295);
357+
/// ```
348358
#[stable(feature = "rust1", since = "1.0.0")]
349359
#[inline]
350360
fn saturating_add(self, other: Self) -> Self {
@@ -357,6 +367,16 @@ pub trait Int
357367

358368
/// Saturating integer subtraction. Computes `self - other`, saturating at
359369
/// the numeric bounds instead of overflowing.
370+
///
371+
/// # Examples
372+
///
373+
/// ```
374+
/// use std::num::Int;
375+
///
376+
/// assert_eq!(5u16.saturating_sub(65534), 0);
377+
/// assert_eq!(5i16.saturating_sub(-32767), 32767);
378+
/// assert_eq!(100u32.saturating_sub(4294967294), 0);
379+
/// ```
360380
#[stable(feature = "rust1", since = "1.0.0")]
361381
#[inline]
362382
fn saturating_sub(self, other: Self) -> Self {

0 commit comments

Comments
 (0)