summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-04-09 10:53:36 +0000
committerGitHub <noreply@github.com>2023-04-09 10:53:36 +0000
commit1d0db8935a8f6861368bdcd0e270cd913d067aa1 (patch)
tree8d0b964e9366f58f31cec508b7da8e3ad4c2309f
parent6f2bdbadde2d690191d940681297207e1e451f40 (diff)
parentb06967e9b05ebe8491f8e06619b3e6a398958f9b (diff)
Merge #6
6: Add documentation on extension traits r=matthiasbeyer a=matthiasbeyer Co-authored-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;
}