@@ -128,11 +128,11 @@ impl Compositor {
129 /// Replace a component that has the given `id` with the new layer and if
129 /// Replace a component that has the given `id` with the new layer and if
130 /// no component is found, push the layer normally.
130 /// no component is found, push the layer normally.
131− pub fn replace_or_push(&mut self, id: &'static str, layer: Box<dyn Component>) {
131+ pub fn replace_or_push<T: Component>(&mut self, id: &'static str, layer: T) {
132 if let Some(component) = self.find_id(id) {
132 if let Some(component) = self.find_id(id) {
133 *component = layer;
133 *component = layer;
135− self.push(layer)
135+ self.push(Box::new(layer))
@@ -221,10 +221,9 @@ impl Compositor {
223 pub fn find_id<T: 'static>(&mut self, id: &'static str) -> Option<&mut T> {
223 pub fn find_id<T: 'static>(&mut self, id: &'static str) -> Option<&mut T> {
224− let type_name = std::any::type_name::<T>();
225 self.layers
224 self.layers
226 .iter_mut()
225 .iter_mut()
227− .find(|component| component.type_name() == type_name && component.id() == Some(id))
226+ .find(|component| component.id() == Some(id))
228 .and_then(|component| component.as_any_mut().downcast_mut())
227 .and_then(|component| component.as_any_mut().downcast_mut())