File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
branches/beta/src/libcore/num Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
31
31
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
32
32
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
33
33
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34
- refs/heads/beta: 97f03e7ad91cec9715fefbc8112519bd7c01e756
34
+ refs/heads/beta: 4294327886ed7c1a21148f86941418a8a5950381
35
35
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
36
36
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37
37
refs/heads/tmp: de8a23bbc3a7b9cbd7574b5b91a34af59bf030e6
Original file line number Diff line number Diff line change @@ -345,6 +345,16 @@ pub trait Int
345
345
346
346
/// Saturating integer addition. Computes `self + other`, saturating at
347
347
/// 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
+ /// ```
348
358
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
349
359
#[ inline]
350
360
fn saturating_add ( self , other : Self ) -> Self {
@@ -357,6 +367,16 @@ pub trait Int
357
367
358
368
/// Saturating integer subtraction. Computes `self - other`, saturating at
359
369
/// 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
+ /// ```
360
380
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
361
381
#[ inline]
362
382
fn saturating_sub ( self , other : Self ) -> Self {
You can’t perform that action at this time.
0 commit comments