disallow some methods from itertools

This commit is contained in:
Luna Yao
2026-04-06 18:28:30 +02:00
parent 6af62e939e
commit 5a8a1d3e6b
11 changed files with 44 additions and 40 deletions
+7 -4
View File
@@ -1,7 +1,5 @@
use crate::utils::MapTryInto;
use derivative::Derivative;
use derive_more::{Deref, DerefMut, From, IntoIterator};
use itertools::Itertools;
use serde::{Deserialize, Serialize};
pub trait MessageModel<Message: prost::Message>:
@@ -49,7 +47,12 @@ where
type Error = <Model as TryFrom<&'m Message>>::Error;
fn try_from(value: &'m Vec<Message>) -> Result<Self, Self::Error> {
Ok(Self(value.iter().map_try_into().try_collect()?))
Ok(Self(
value
.iter()
.map(TryInto::try_into)
.collect::<Result<_, _>>()?,
))
}
}
@@ -59,6 +62,6 @@ where
Model: MessageModel<Message>,
{
fn from(value: RepeatedMessageModel<Model>) -> Self {
value.into_iter().map_into().collect()
value.into_iter().map(Into::into).collect()
}
}