Skip to content

Commit 8682553

Browse files
committed
Add examples to dec/inc
1 parent 9d4d68b commit 8682553

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/lib.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,33 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
336336
self.clone() - self.mod_floor(other)
337337
}
338338

339-
/// Decrements self.
339+
/// Decrements self by one.
340+
///
341+
/// # Examples
342+
///
343+
/// ~~~
344+
/// # use num_integer::Integer;
345+
/// let mut x: i32 = 43;
346+
/// x.dec();
347+
/// assert_eq!(x, 42);
348+
/// ~~~
340349
fn dec(&mut self)
341350
where
342351
Self: Clone,
343352
{
344353
*self = self.clone() - Self::one()
345354
}
346355

347-
/// Increments self.
356+
/// Increments self by one.
357+
///
358+
/// # Examples
359+
///
360+
/// ~~~
361+
/// # use num_integer::Integer;
362+
/// let mut x: i32 = 41;
363+
/// x.inc();
364+
/// assert_eq!(x, 42);
365+
/// ~~~
348366
fn inc(&mut self)
349367
where
350368
Self: Clone,

0 commit comments

Comments
 (0)