mutate many

master
Avril 4 years ago
parent 7dc820317e
commit f67d487a84
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -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"]

@ -134,7 +134,7 @@ where U: IntoIterator<Item = T>
false
}
}
/// Map the single value with this function
/// Map the many value with this function
#[inline] pub fn map_many<F, A>(self, fun: F) -> MaybeMany<T, A>
where F: FnOnce(U) -> A,
A: IntoIterator<Item=T>
@ -146,6 +146,16 @@ where U: IntoIterator<Item = T>
}
}
/// Mutate the many value with this function.
#[inline] pub fn on_many<F, A>(&mut self, fun: F) -> Option<A>
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<F>(self, fun: F) -> MaybeMany<T,U>
where F: FnOnce(T) -> T

Loading…
Cancel
Save