diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2023-04-09 12:51:09 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2023-04-09 12:51:09 +0200 |
commit | b06967e9b05ebe8491f8e06619b3e6a398958f9b (patch) | |
tree | 704fb146723b0c1db75786e56acf1d2161f4d1bd | |
parent | 276eca246349f00f464e1ea3652b128c1ae1fee9 (diff) |
Add documentation on extension traits
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/lib.rs | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -1,11 +1,15 @@ //! This crate adds the missing Option::inspect function via an extension trait //! +/// Extension trait for adding Option::inspect pub trait OptionInspect<F, T> where F: FnOnce(&T), T: Sized, { + /// Inspect the Option + /// + /// Either call `f` on the value in `Some` or do nothing if this Option is a None. fn inspect(self, f: F) -> Self; } @@ -43,10 +47,12 @@ where } } +/// Extension trait for adding Option::inspect_none pub trait OptionInspectNone<F> where F: FnOnce(), { + /// Call `f` if the Option this is called on is a None fn inspect_none(self, f: F) -> Self; } |