File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments