summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2023-04-09 12:51:09 +0200
committerMatthias Beyer <mail@beyermatthias.de>2023-04-09 12:51:09 +0200
commitb06967e9b05ebe8491f8e06619b3e6a398958f9b (patch)
tree704fb146723b0c1db75786e56acf1d2161f4d1bd
parent276eca246349f00f464e1ea3652b128c1ae1fee9 (diff)
Add documentation on extension traits
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/lib.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6b120de..de501d6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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;
}