use the standard `From` trait instead of `IntoEventHandler`

This commit is contained in:
Matthew Nicholson 2019-03-31 01:02:55 -04:00
parent 559359b2ff
commit 44436da495
1 changed files with 4 additions and 14 deletions

View File

@ -6,7 +6,7 @@ use stdweb::web::{self, Element, EventListenerHandle, IElement, IEventTarget, IN
use crate::OutputType; use crate::OutputType;
use crate::dom::VNode; use crate::dom::VNode;
use crate::events::{EventHandler, IntoEventHandler}; use crate::events::EventHandler;
/// DOM output using the stdweb crate /// DOM output using the stdweb crate
pub struct Stdweb; pub struct Stdweb;
@ -136,23 +136,13 @@ where
} }
} }
impl<F, E> IntoEventHandler<Stdweb, E> for F impl<F, E> From<F> for Box<dyn EventHandler<Stdweb, E>>
where where
F: FnMut(E) + 'static, F: FnMut(E) + 'static,
E: ConcreteEvent + 'static, E: ConcreteEvent + 'static,
{ {
fn into_event_handler(self) -> Box<dyn EventHandler<Stdweb, E>> { fn from(f: F) -> Self {
Box::new(EFn::new(self)) Box::new(EFn::new(f))
}
}
impl<F, E> IntoEventHandler<Stdweb, E> for EFn<F, E>
where
F: FnMut(E) + 'static,
E: ConcreteEvent + 'static,
{
fn into_event_handler(self) -> Box<dyn EventHandler<Stdweb, E>> {
Box::new(self)
} }
} }