fix any value dropping

This commit is contained in:
Evan Almloff committed 2023-01-02 21:26:12 -06:00
1 parent 51dba50c04
commit c0f9355648
7 files changed
+43 -36

No files matched your search

+1 -20
View File
@@ -48,20 +48,7 @@ impl<'a> Mutations<'a> {
/// Push a new mutation into the dom_edits list
pub(crate) fn push(&mut self, mutation: Mutation<'static>) {
self.edits.push(mutation.downcast_lifetime())
}
}
impl Mutations<'static> {
pub(crate) fn take<'a>(&mut self) -> Mutations<'a> {
Mutations::<'a> {
subtree: self.subtree,
dirty_scopes: self.dirty_scopes.drain().collect(),
templates: self.templates.split_off(0),
// Safety: this downcasts the lifetime from 'static to 'a
// This is safe because 'static outlives 'a
edits: unsafe { std::mem::transmute(self.edits.split_off(0)) },
}
self.edits.push(mutation)
}
}
@@ -257,9 +244,3 @@ pub enum Mutation<'a> {
id: ElementId,
},
}
impl Mutation<'static> {
pub(crate) fn downcast_lifetime<'a>(self) -> Mutation<'a> {
unsafe { std::mem::transmute(self) }
}
}