Hide Box allocation in component::view

... we may be able to avoid it with generics in the future.
This commit is contained in:
Héctor Ramón Jiménez 2021-11-08 15:32:58 +07:00
parent 010b62b9ee
commit f7792d89d6
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 5 additions and 5 deletions

View file

@ -174,7 +174,7 @@ mod numeric_input {
Renderer: text::Renderer + 'a,
{
fn from(numeric_input: NumericInput<'a, Message>) -> Self {
component::view(Box::new(numeric_input))
component::view(numeric_input)
}
}
}

View file

@ -10,18 +10,18 @@ use iced_native::{
use ouroboros::self_referencing;
use std::marker::PhantomData;
pub fn view<'a, Event, Message, Renderer>(
component: Box<dyn Component<Message, Renderer, Event = Event> + 'a>,
pub fn view<'a, C, Message, Renderer>(
component: C,
) -> Element<'a, Message, Renderer>
where
C: Component<Message, Renderer> + 'a,
Message: 'a,
Event: 'a,
Renderer: iced_native::Renderer + 'a,
{
Element::new(Instance {
state: Some(
StateBuilder {
component,
component: Box::new(component),
cache_builder: |state| Cache {
element: state.view(),
message: PhantomData,