mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-03 01:25:37 +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 {}
|
impl<S: Serialize> DeterministicDigest for S {}
|
||||||
|
|
||||||
pub trait MapTryInto<S> {
|
pub trait MapTryInto: Iterator + Sized {
|
||||||
fn map_try_into<T: TryFrom<S>>(self) -> impl Iterator<Item = Result<T, T::Error>>;
|
fn map_try_into<R>(self) -> impl Iterator<Item = Result<R, <Self::Item as TryInto<R>>::Error>>
|
||||||
}
|
where
|
||||||
|
Self::Item: TryInto<R>,
|
||||||
impl<I, S> MapTryInto<S> for I
|
{
|
||||||
where
|
self.into_iter().map(Self::Item::try_into)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> MapTryInto for T where T: Iterator + Sized {}
|
||||||
|
|||||||
Reference in New Issue
Block a user