1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#![allow(clippy::future_not_send)]
#![allow(clippy::unused_async)]
pub mod chat;
pub mod media;
pub mod message;
mod traits;
use futures::{future::BoxFuture, Future};
use std::sync::Arc;
pub use traits::{
PredicateBooleanOperations, StatefulPredicateBooleanOperations,
};
pub fn without_state<'a, C, P, S, F>(
predicate: P,
) -> impl Fn(Arc<C>, Arc<S>) -> BoxFuture<'a, bool> + Send + Sync + 'a
where
P: PredicateBooleanOperations<C, F>,
F: Future<Output = bool> + Send,
C: Send + Sync + 'static,
S: Send + Sync + 'static,
{
let predicate = Arc::new(predicate);
move |ctx, _state| {
let predicate = Arc::clone(&predicate);
Box::pin(async move { predicate(ctx).await })
}
}