mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2025-12-18 13:18:55 -05:00
apply new rustfmt.toml changes, fix some clippy lints
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
0317cc8cc5
commit
77e0b76408
296 changed files with 7147 additions and 4300 deletions
|
|
@ -14,9 +14,13 @@ where
|
|||
Item: 'a,
|
||||
{
|
||||
#[inline]
|
||||
fn expect_ok(self: T) -> impl Stream<Item = Item> + Send + 'a { self.map_expect("stream expectation failure") }
|
||||
fn expect_ok(self: T) -> impl Stream<Item = Item> + Send + 'a {
|
||||
self.map_expect("stream expectation failure")
|
||||
}
|
||||
|
||||
//TODO: move to impl MapExpect
|
||||
#[inline]
|
||||
fn map_expect(self, msg: &'a str) -> impl Stream<Item = Item> + Send + 'a { self.map(|res| res.expect(msg)) }
|
||||
fn map_expect(self, msg: &'a str) -> impl Stream<Item = Item> + Send + 'a {
|
||||
self.map(|res| res.expect(msg))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,12 @@ where
|
|||
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[inline]
|
||||
fn ignore_err(self: T) -> impl Stream<Item = Item> + Send + 'a { self.filter_map(|res| ready(res.ok())) }
|
||||
fn ignore_err(self: T) -> impl Stream<Item = Item> + Send + 'a {
|
||||
self.filter_map(|res| ready(res.ok()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn ignore_ok(self: T) -> impl Stream<Item = Error> + Send + 'a { self.filter_map(|res| ready(res.err())) }
|
||||
fn ignore_ok(self: T) -> impl Stream<Item = Error> + Send + 'a {
|
||||
self.filter_map(|res| ready(res.err()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,11 @@ pub trait IterStream<I: IntoIterator + Send> {
|
|||
/// Convert an Iterator into a TryStream
|
||||
fn try_stream(
|
||||
self,
|
||||
) -> impl TryStream<Ok = <I as IntoIterator>::Item, Error = Error, Item = Result<<I as IntoIterator>::Item, Error>> + Send;
|
||||
) -> impl TryStream<
|
||||
Ok = <I as IntoIterator>::Item,
|
||||
Error = Error,
|
||||
Item = Result<<I as IntoIterator>::Item, Error>,
|
||||
> + Send;
|
||||
}
|
||||
|
||||
impl<I> IterStream<I> for I
|
||||
|
|
@ -27,8 +31,11 @@ where
|
|||
#[inline]
|
||||
fn try_stream(
|
||||
self,
|
||||
) -> impl TryStream<Ok = <I as IntoIterator>::Item, Error = Error, Item = Result<<I as IntoIterator>::Item, Error>> + Send
|
||||
{
|
||||
) -> impl TryStream<
|
||||
Ok = <I as IntoIterator>::Item,
|
||||
Error = Error,
|
||||
Item = Result<<I as IntoIterator>::Item, Error>,
|
||||
> + Send {
|
||||
self.stream().map(Ok)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
|
||||
use futures::{
|
||||
future::{ready, Ready},
|
||||
stream::{All, Any, Filter, FilterMap, Fold, ForEach, Scan, SkipWhile, Stream, StreamExt, TakeWhile},
|
||||
stream::{
|
||||
All, Any, Filter, FilterMap, Fold, ForEach, Scan, SkipWhile, Stream, StreamExt, TakeWhile,
|
||||
},
|
||||
};
|
||||
|
||||
/// Synchronous combinators to augment futures::StreamExt. Most Stream
|
||||
|
|
@ -24,19 +26,32 @@ where
|
|||
where
|
||||
F: Fn(Item) -> bool;
|
||||
|
||||
fn ready_filter<'a, F>(self, f: F) -> Filter<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
fn ready_filter<'a, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> Filter<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
where
|
||||
F: Fn(&Item) -> bool + 'a;
|
||||
|
||||
fn ready_filter_map<F, U>(self, f: F) -> FilterMap<Self, Ready<Option<U>>, impl FnMut(Item) -> Ready<Option<U>>>
|
||||
fn ready_filter_map<F, U>(
|
||||
self,
|
||||
f: F,
|
||||
) -> FilterMap<Self, Ready<Option<U>>, impl FnMut(Item) -> Ready<Option<U>>>
|
||||
where
|
||||
F: Fn(Item) -> Option<U>;
|
||||
|
||||
fn ready_fold<T, F>(self, init: T, f: F) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>>
|
||||
fn ready_fold<T, F>(
|
||||
self,
|
||||
init: T,
|
||||
f: F,
|
||||
) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>>
|
||||
where
|
||||
F: Fn(T, Item) -> T;
|
||||
|
||||
fn ready_fold_default<T, F>(self, f: F) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>>
|
||||
fn ready_fold_default<T, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>>
|
||||
where
|
||||
F: Fn(T, Item) -> T,
|
||||
T: Default;
|
||||
|
|
@ -45,23 +60,33 @@ where
|
|||
where
|
||||
F: FnMut(Item);
|
||||
|
||||
fn ready_take_while<'a, F>(self, f: F) -> TakeWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
fn ready_take_while<'a, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> TakeWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
where
|
||||
F: Fn(&Item) -> bool + 'a;
|
||||
|
||||
fn ready_scan<B, T, F>(
|
||||
self, init: T, f: F,
|
||||
self,
|
||||
init: T,
|
||||
f: F,
|
||||
) -> Scan<Self, T, Ready<Option<B>>, impl FnMut(&mut T, Item) -> Ready<Option<B>>>
|
||||
where
|
||||
F: Fn(&mut T, Item) -> Option<B>;
|
||||
|
||||
fn ready_scan_each<T, F>(
|
||||
self, init: T, f: F,
|
||||
self,
|
||||
init: T,
|
||||
f: F,
|
||||
) -> Scan<Self, T, Ready<Option<Item>>, impl FnMut(&mut T, Item) -> Ready<Option<Item>>>
|
||||
where
|
||||
F: Fn(&mut T, &Item);
|
||||
|
||||
fn ready_skip_while<'a, F>(self, f: F) -> SkipWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
fn ready_skip_while<'a, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> SkipWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
where
|
||||
F: Fn(&Item) -> bool + 'a;
|
||||
}
|
||||
|
|
@ -87,7 +112,10 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn ready_filter<'a, F>(self, f: F) -> Filter<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
fn ready_filter<'a, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> Filter<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
where
|
||||
F: Fn(&Item) -> bool + 'a,
|
||||
{
|
||||
|
|
@ -95,7 +123,10 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn ready_filter_map<F, U>(self, f: F) -> FilterMap<Self, Ready<Option<U>>, impl FnMut(Item) -> Ready<Option<U>>>
|
||||
fn ready_filter_map<F, U>(
|
||||
self,
|
||||
f: F,
|
||||
) -> FilterMap<Self, Ready<Option<U>>, impl FnMut(Item) -> Ready<Option<U>>>
|
||||
where
|
||||
F: Fn(Item) -> Option<U>,
|
||||
{
|
||||
|
|
@ -103,7 +134,11 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn ready_fold<T, F>(self, init: T, f: F) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>>
|
||||
fn ready_fold<T, F>(
|
||||
self,
|
||||
init: T,
|
||||
f: F,
|
||||
) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>>
|
||||
where
|
||||
F: Fn(T, Item) -> T,
|
||||
{
|
||||
|
|
@ -111,7 +146,10 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn ready_fold_default<T, F>(self, f: F) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>>
|
||||
fn ready_fold_default<T, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>>
|
||||
where
|
||||
F: Fn(T, Item) -> T,
|
||||
T: Default,
|
||||
|
|
@ -121,7 +159,10 @@ where
|
|||
|
||||
#[inline]
|
||||
#[allow(clippy::unit_arg)]
|
||||
fn ready_for_each<F>(self, mut f: F) -> ForEach<Self, Ready<()>, impl FnMut(Item) -> Ready<()>>
|
||||
fn ready_for_each<F>(
|
||||
self,
|
||||
mut f: F,
|
||||
) -> ForEach<Self, Ready<()>, impl FnMut(Item) -> Ready<()>>
|
||||
where
|
||||
F: FnMut(Item),
|
||||
{
|
||||
|
|
@ -129,7 +170,10 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn ready_take_while<'a, F>(self, f: F) -> TakeWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
fn ready_take_while<'a, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> TakeWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
where
|
||||
F: Fn(&Item) -> bool + 'a,
|
||||
{
|
||||
|
|
@ -138,7 +182,9 @@ where
|
|||
|
||||
#[inline]
|
||||
fn ready_scan<B, T, F>(
|
||||
self, init: T, f: F,
|
||||
self,
|
||||
init: T,
|
||||
f: F,
|
||||
) -> Scan<Self, T, Ready<Option<B>>, impl FnMut(&mut T, Item) -> Ready<Option<B>>>
|
||||
where
|
||||
F: Fn(&mut T, Item) -> Option<B>,
|
||||
|
|
@ -148,7 +194,9 @@ where
|
|||
|
||||
#[inline]
|
||||
fn ready_scan_each<T, F>(
|
||||
self, init: T, f: F,
|
||||
self,
|
||||
init: T,
|
||||
f: F,
|
||||
) -> Scan<Self, T, Ready<Option<Item>>, impl FnMut(&mut T, Item) -> Ready<Option<Item>>>
|
||||
where
|
||||
F: Fn(&mut T, &Item),
|
||||
|
|
@ -160,7 +208,10 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn ready_skip_while<'a, F>(self, f: F) -> SkipWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
fn ready_skip_while<'a, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> SkipWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
|
||||
where
|
||||
F: Fn(&Item) -> bool + 'a,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,12 +24,17 @@ where
|
|||
F: Fn(Item) -> K + Send,
|
||||
K: Eq + Hash + Send;
|
||||
|
||||
fn counts_by_with_cap<const CAP: usize, K, F>(self, f: F) -> impl Future<Output = HashMap<K, usize>> + Send
|
||||
fn counts_by_with_cap<const CAP: usize, K, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> impl Future<Output = HashMap<K, usize>> + Send
|
||||
where
|
||||
F: Fn(Item) -> K + Send,
|
||||
K: Eq + Hash + Send;
|
||||
|
||||
fn counts_with_cap<const CAP: usize>(self) -> impl Future<Output = HashMap<Item, usize>> + Send
|
||||
fn counts_with_cap<const CAP: usize>(
|
||||
self,
|
||||
) -> impl Future<Output = HashMap<Item, usize>> + Send
|
||||
where
|
||||
<Self as Stream>::Item: Eq + Hash;
|
||||
|
||||
|
|
@ -63,7 +68,10 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn counts_by_with_cap<const CAP: usize, K, F>(self, f: F) -> impl Future<Output = HashMap<K, usize>> + Send
|
||||
fn counts_by_with_cap<const CAP: usize, K, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> impl Future<Output = HashMap<K, usize>> + Send
|
||||
where
|
||||
F: Fn(Item) -> K + Send,
|
||||
K: Eq + Hash + Send,
|
||||
|
|
@ -72,7 +80,9 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn counts_with_cap<const CAP: usize>(self) -> impl Future<Output = HashMap<Item, usize>> + Send
|
||||
fn counts_with_cap<const CAP: usize>(
|
||||
self,
|
||||
) -> impl Future<Output = HashMap<Item, usize>> + Send
|
||||
where
|
||||
<Self as Stream>::Item: Eq + Hash,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,13 +12,20 @@ pub trait TryBroadbandExt<T, E>
|
|||
where
|
||||
Self: TryStream<Ok = T, Error = E, Item = Result<T, E>> + Send + Sized,
|
||||
{
|
||||
fn broadn_and_then<U, F, Fut, N>(self, n: N, f: F) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
|
||||
fn broadn_and_then<U, F, Fut, N>(
|
||||
self,
|
||||
n: N,
|
||||
f: F,
|
||||
) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
|
||||
where
|
||||
N: Into<Option<usize>>,
|
||||
F: Fn(Self::Ok) -> Fut + Send + Sync,
|
||||
Fut: TryFuture<Ok = U, Error = E, Output = Result<U, E>> + Send;
|
||||
|
||||
fn broad_and_then<U, F, Fut>(self, f: F) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
|
||||
fn broad_and_then<U, F, Fut>(
|
||||
self,
|
||||
f: F,
|
||||
) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
|
||||
where
|
||||
F: Fn(Self::Ok) -> Fut + Send + Sync,
|
||||
Fut: TryFuture<Ok = U, Error = E, Output = Result<U, E>> + Send,
|
||||
|
|
@ -31,7 +38,11 @@ impl<T, E, S> TryBroadbandExt<T, E> for S
|
|||
where
|
||||
S: TryStream<Ok = T, Error = E, Item = Result<T, E>> + Send + Sized,
|
||||
{
|
||||
fn broadn_and_then<U, F, Fut, N>(self, n: N, f: F) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
|
||||
fn broadn_and_then<U, F, Fut, N>(
|
||||
self,
|
||||
n: N,
|
||||
f: F,
|
||||
) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
|
||||
where
|
||||
N: Into<Option<usize>>,
|
||||
F: Fn(Self::Ok) -> Fut + Send + Sync,
|
||||
|
|
|
|||
|
|
@ -16,31 +16,43 @@ where
|
|||
S: TryStream<Ok = T, Error = E, Item = Result<T, E>> + Send + ?Sized,
|
||||
Self: TryStream + Send + Sized,
|
||||
{
|
||||
fn ready_and_then<U, F>(self, f: F) -> AndThen<Self, Ready<Result<U, E>>, impl FnMut(S::Ok) -> Ready<Result<U, E>>>
|
||||
fn ready_and_then<U, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> AndThen<Self, Ready<Result<U, E>>, impl FnMut(S::Ok) -> Ready<Result<U, E>>>
|
||||
where
|
||||
F: Fn(S::Ok) -> Result<U, E>;
|
||||
|
||||
fn ready_try_filter_map<F, U>(
|
||||
self, f: F,
|
||||
) -> TryFilterMap<Self, Ready<Result<Option<U>, E>>, impl FnMut(S::Ok) -> Ready<Result<Option<U>, E>>>
|
||||
self,
|
||||
f: F,
|
||||
) -> TryFilterMap<
|
||||
Self,
|
||||
Ready<Result<Option<U>, E>>,
|
||||
impl FnMut(S::Ok) -> Ready<Result<Option<U>, E>>,
|
||||
>
|
||||
where
|
||||
F: Fn(S::Ok) -> Result<Option<U>, E>;
|
||||
|
||||
fn ready_try_fold<U, F>(
|
||||
self, init: U, f: F,
|
||||
self,
|
||||
init: U,
|
||||
f: F,
|
||||
) -> TryFold<Self, Ready<Result<U, E>>, U, impl FnMut(U, S::Ok) -> Ready<Result<U, E>>>
|
||||
where
|
||||
F: Fn(U, S::Ok) -> Result<U, E>;
|
||||
|
||||
fn ready_try_fold_default<U, F>(
|
||||
self, f: F,
|
||||
self,
|
||||
f: F,
|
||||
) -> TryFold<Self, Ready<Result<U, E>>, U, impl FnMut(U, S::Ok) -> Ready<Result<U, E>>>
|
||||
where
|
||||
F: Fn(U, S::Ok) -> Result<U, E>,
|
||||
U: Default;
|
||||
|
||||
fn ready_try_for_each<F>(
|
||||
self, f: F,
|
||||
self,
|
||||
f: F,
|
||||
) -> TryForEach<Self, Ready<Result<(), E>>, impl FnMut(S::Ok) -> Ready<Result<(), E>>>
|
||||
where
|
||||
F: FnMut(S::Ok) -> Result<(), E>;
|
||||
|
|
@ -52,7 +64,10 @@ where
|
|||
Self: TryStream + Send + Sized,
|
||||
{
|
||||
#[inline]
|
||||
fn ready_and_then<U, F>(self, f: F) -> AndThen<Self, Ready<Result<U, E>>, impl FnMut(S::Ok) -> Ready<Result<U, E>>>
|
||||
fn ready_and_then<U, F>(
|
||||
self,
|
||||
f: F,
|
||||
) -> AndThen<Self, Ready<Result<U, E>>, impl FnMut(S::Ok) -> Ready<Result<U, E>>>
|
||||
where
|
||||
F: Fn(S::Ok) -> Result<U, E>,
|
||||
{
|
||||
|
|
@ -60,8 +75,13 @@ where
|
|||
}
|
||||
|
||||
fn ready_try_filter_map<F, U>(
|
||||
self, f: F,
|
||||
) -> TryFilterMap<Self, Ready<Result<Option<U>, E>>, impl FnMut(S::Ok) -> Ready<Result<Option<U>, E>>>
|
||||
self,
|
||||
f: F,
|
||||
) -> TryFilterMap<
|
||||
Self,
|
||||
Ready<Result<Option<U>, E>>,
|
||||
impl FnMut(S::Ok) -> Ready<Result<Option<U>, E>>,
|
||||
>
|
||||
where
|
||||
F: Fn(S::Ok) -> Result<Option<U>, E>,
|
||||
{
|
||||
|
|
@ -70,7 +90,9 @@ where
|
|||
|
||||
#[inline]
|
||||
fn ready_try_fold<U, F>(
|
||||
self, init: U, f: F,
|
||||
self,
|
||||
init: U,
|
||||
f: F,
|
||||
) -> TryFold<Self, Ready<Result<U, E>>, U, impl FnMut(U, S::Ok) -> Ready<Result<U, E>>>
|
||||
where
|
||||
F: Fn(U, S::Ok) -> Result<U, E>,
|
||||
|
|
@ -80,7 +102,8 @@ where
|
|||
|
||||
#[inline]
|
||||
fn ready_try_fold_default<U, F>(
|
||||
self, f: F,
|
||||
self,
|
||||
f: F,
|
||||
) -> TryFold<Self, Ready<Result<U, E>>, U, impl FnMut(U, S::Ok) -> Ready<Result<U, E>>>
|
||||
where
|
||||
F: Fn(U, S::Ok) -> Result<U, E>,
|
||||
|
|
@ -91,7 +114,8 @@ where
|
|||
|
||||
#[inline]
|
||||
fn ready_try_for_each<F>(
|
||||
self, mut f: F,
|
||||
self,
|
||||
mut f: F,
|
||||
) -> TryForEach<Self, Ready<Result<(), E>>, impl FnMut(S::Ok) -> Ready<Result<(), E>>>
|
||||
where
|
||||
F: FnMut(S::Ok) -> Result<(), E>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue