diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-04-09 10:53:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-09 10:53:36 +0000 |
commit | 1d0db8935a8f6861368bdcd0e270cd913d067aa1 (patch) | |
tree | 8d0b964e9366f58f31cec508b7da8e3ad4c2309f | |
parent | 6f2bdbadde2d690191d940681297207e1e451f40 (diff) | |
parent | b06967e9b05ebe8491f8e06619b3e6a398958f9b (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.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; } |