?play
#[derive(Clone)]
struct Position;
struct MouseEvent;
struct Event(Position, MouseEvent);
trait Context {
fn onclick(&self, e: Event);
}
pub fn make_callback<C: Context>(context: &C, position: &Position)
-> impl Fn(MouseEvent)
{
let position = position.to_owned();
move |x| {
let event = Event (position.clone(), x);
context.onclick(event)
}
}