strafe_trait/
manipulator.rs

1use std::sync::Arc;
2
3#[derive(Clone)]
4pub struct Manipulator<I, O> {
5    manipulator: Arc<dyn Fn(&I) -> O>,
6}
7
8impl<I, O> Manipulator<I, O> {
9    pub fn new(f: Arc<dyn Fn(&I) -> O>) -> Self {
10        Self { manipulator: f }
11    }
12
13    pub fn manipulate(&self, input: &I) -> O {
14        (*self.manipulator)(input)
15    }
16}