Apply suggestions

This commit is contained in:
Guillaume Gomez 2025-05-19 22:50:32 +02:00 committed by René Kijewski
parent c6aa9b2e83
commit 36fd13d3b2
2 changed files with 11 additions and 8 deletions

View File

@ -473,11 +473,11 @@ impl<S: FastWritable, P: FastWritable> FastWritable for Pluralize<S, P> {
/// "b,c,"
/// );
/// ```
pub fn reject<T: PartialEq>(
it: impl IntoIterator<Item = T>,
filter: T,
) -> Result<impl Iterator<Item = T>, Infallible> {
Ok(it.into_iter().filter(move |v| v != &filter))
pub fn reject<'a, T: PartialEq, U: IntoIterator<Item = T>>(
it: U,
filter: &'a T,
) -> Result<impl Iterator<Item = T> + use<'a, T, U>, Infallible> {
Ok(it.into_iter().filter(move |v| v != filter))
}
/// Returns an iterator without filtered out values.
@ -505,9 +505,9 @@ pub fn reject<T: PartialEq>(
/// );
/// }
/// ```
pub fn reject_with<T: PartialEq, F: Fn(&T) -> bool>(
pub fn reject_with<T: PartialEq, F: FnMut(&T) -> bool>(
it: impl IntoIterator<Item = T>,
callback: F,
mut callback: F,
) -> Result<impl Iterator<Item = T>, Infallible> {
Ok(it.into_iter().filter(move |v| !callback(v)))
}

View File

@ -260,9 +260,12 @@ impl<'a> Generator<'a, '_> {
self.visit_arg(ctx, buf, input)?;
buf.write(',');
if extra_ampersand {
buf.write('&');
buf.write("&&(");
}
self.visit_arg(ctx, buf, filter)?;
if extra_ampersand {
buf.write(')');
}
buf.write(")?");
Ok(DisplayWrap::Wrapped)
}