mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-08-08 05:29:47 +00:00
utils: add MapTryInto
This commit is contained in:
@@ -161,3 +161,16 @@ 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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user