simple_ref_fn/
static_ref_mut_function.rs1use crate::ref_fn_mut::RefFnMut;
2use crate::ref_send_fn_mut::RefSendFnMut;
3
4pub trait StaticRefMutFunction<'a, D, T> {
6 type Output;
8
9 fn call_mut(data: &'a mut D, arg: T) -> Self::Output;
11
12 fn bind(data: &'a mut D) -> RefFnMut<'a, T, Self::Output> {
14 RefFnMut::new::<Self, D>(data)
15 }
16
17 fn bind_send(data: &'a mut D) -> RefSendFnMut<'a, T, Self::Output>
19 where
20 D: Send,
21 {
22 RefSendFnMut::new::<Self, D>(data)
23 }
24}
25
26impl<'a, T, F, R> StaticRefMutFunction<'a, F, T> for F
27where
28 F: FnMut(T) -> R,
29{
30 type Output = R;
31
32 fn call_mut(data: &'a mut Self, arg: T) -> Self::Output {
33 (*data)(arg)
34 }
35}