mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-08-07 21:19:51 +00:00
utils: update MapTryInto to match behaviour of itertools
This commit is contained in:
+8
-10
@@ -162,15 +162,13 @@ pub trait DeterministicDigest: Serialize {
|
||||
|
||||
impl<S: Serialize> DeterministicDigest for S {}
|
||||
|
||||
pub trait MapTryInto<S> {
|
||||
fn map_try_into<T: TryFrom<S>>(self) -> impl Iterator<Item = Result<T, T::Error>>;
|
||||
}
|
||||
|
||||
impl<I, S> MapTryInto<S> for I
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
{
|
||||
fn map_try_into<T: TryFrom<S>>(self) -> impl Iterator<Item = Result<T, T::Error>> {
|
||||
self.into_iter().map(T::try_from)
|
||||
pub trait MapTryInto: Iterator + Sized {
|
||||
fn map_try_into<R>(self) -> impl Iterator<Item = Result<R, <Self::Item as TryInto<R>>::Error>>
|
||||
where
|
||||
Self::Item: TryInto<R>,
|
||||
{
|
||||
self.into_iter().map(Self::Item::try_into)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> MapTryInto for T where T: Iterator + Sized {}
|
||||
|
||||
Reference in New Issue
Block a user