Start work on generalizing the BlockMap to allow arbitrary elements

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2021-12-01 15:25:55 -08:00
parent e668ff8bcd
commit 0c714210ff
7 changed files with 579 additions and 897 deletions

View file

@ -301,6 +301,10 @@ impl<T: Element> Default for Lifecycle<T> {
}
impl ElementBox {
pub fn name(&self) -> Option<&str> {
self.0.name.as_deref()
}
pub fn metadata<T: 'static>(&self) -> Option<&T> {
let element = unsafe { &*self.0.element.as_ptr() };
element.metadata().and_then(|m| m.downcast_ref())