diff --git a/Cargo.toml b/Cargo.toml index 8ef892a..f044dc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ad-hoc-iter" -version = "0.2.1" +version = "0.2.2" description = "Ad-hoc exact size owning iterator macro and other optional utils" repository = "https://git.flanchan.moe/flanchan/ad-hoc-iter" keywords = ["iterator", "macro", "iter"] diff --git a/src/maybe.rs b/src/maybe.rs index ce27d84..2e13001 100644 --- a/src/maybe.rs +++ b/src/maybe.rs @@ -134,7 +134,7 @@ where U: IntoIterator false } } - /// Map the single value with this function + /// Map the many value with this function #[inline] pub fn map_many(self, fun: F) -> MaybeMany where F: FnOnce(U) -> A, A: IntoIterator @@ -146,6 +146,16 @@ where U: IntoIterator } } + /// Mutate the many value with this function. + #[inline] pub fn on_many(&mut self, fun: F) -> Option + where F: FnOnce(&mut U) -> A, + { + match self { + Self::Many(ref mut m) => Some(fun(m)), + _ => None + } + } + /// Map the single value with this function #[inline] fn map_one(self, fun: F) -> MaybeMany where F: FnOnce(T) -> T