diff --git a/src/components/select.rs b/src/components/select.rs index 3b1dc6b768d..31947516373 100644 --- a/src/components/select.rs +++ b/src/components/select.rs @@ -16,7 +16,7 @@ //! } use crate::callback::Callback; -use crate::html::{ChangeData, Component, ComponentLink, Html, Renderable, ShouldRender}; +use crate::html::{ChangeData, Component, ComponentLink, Html, ShouldRender}; use crate::macros::{html, Properties}; /// `Select` component. @@ -46,7 +46,7 @@ pub struct Props { impl Component for Select where - T: PartialEq + Clone + 'static, + T: ToString + PartialEq + Clone + 'static, { type Message = Msg; type Properties = Props; @@ -73,13 +73,8 @@ where self.props = props; true } -} -impl Renderable> for Select -where - T: ToString + PartialEq + Clone + 'static, -{ - fn view(&self) -> Html { + fn render(&self) -> Html { let selected = self.props.selected.as_ref(); let view_option = |value: &T| { let flag = selected == Some(value); diff --git a/src/html.rs b/src/html.rs index 0399012da3b..042b3739a97 100644 --- a/src/html.rs +++ b/src/html.rs @@ -34,6 +34,8 @@ pub trait Component: Sized + 'static { fn change(&mut self, _: Self::Properties) -> ShouldRender { true } + /// Called by rendering loop. + fn render(&self) -> Html; /// Called for finalization on the final point of the component's lifetime. fn destroy(&mut self) {} // TODO Replace with `Drop` } @@ -68,6 +70,12 @@ pub trait Renderable { fn view(&self) -> Html; } +impl Renderable for COMP { + fn view(&self) -> Html { + self.render() + } +} + /// Updates for a `Components` instance. Used by scope sender. pub(crate) enum ComponentUpdate { /// Wraps messages for a component.