aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/compositor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/compositor.rs')
-rw-r--r--helix-term/src/compositor.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs
index 2f80de00..4f988ace 100644
--- a/helix-term/src/compositor.rs
+++ b/helix-term/src/compositor.rs
@@ -128,11 +128,11 @@ impl Compositor {
/// Replace a component that has the given `id` with the new layer and if
/// no component is found, push the layer normally.
- pub fn replace_or_push(&mut self, id: &'static str, layer: Box<dyn Component>) {
+ pub fn replace_or_push<T: Component>(&mut self, id: &'static str, layer: T) {
if let Some(component) = self.find_id(id) {
*component = layer;
} else {
- self.push(layer)
+ self.push(Box::new(layer))
}
}
@@ -221,10 +221,9 @@ impl Compositor {
}
pub fn find_id<T: 'static>(&mut self, id: &'static str) -> Option<&mut T> {
- let type_name = std::any::type_name::<T>();
self.layers
.iter_mut()
- .find(|component| component.type_name() == type_name && component.id() == Some(id))
+ .find(|component| component.id() == Some(id))
.and_then(|component| component.as_any_mut().downcast_mut())
}
}