@@ -128,11 +128,11 @@ impl Compositor {
128128
129129 /// Replace a component that has the given `id` with the new layer and if
130130 /// 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) {
132132 if let Some(component) = self.find_id(id) {
133133 *component = layer;
134134 } else {
135− self.push(layer)
135+ self.push(Box::new(layer))
136136 }
137137 }
138138
@@ -221,10 +221,9 @@ impl Compositor {
221221 }
222222
223223 pub fn find_id<T: 'static>(&mut self, id: &'static str) -> Option<&mut T> {
224− let type_name = std::any::type_name::<T>();
225224 self.layers
226225 .iter_mut()
227− .find(|component| component.type_name() == type_name && component.id() == Some(id))
226+ .find(|component| component.id() == Some(id))
228227 .and_then(|component| component.as_any_mut().downcast_mut())
229228 }
230229}