Make Widget::diff mutable

This commit is contained in:
Héctor Ramón Jiménez 2025-08-20 23:14:23 +02:00
parent 31bc6d48cd
commit 497ebcd0c3
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
31 changed files with 114 additions and 81 deletions

View file

@ -147,13 +147,13 @@ where
Renderer: renderer::Renderer,
{
fn diff_self(&self) {
self.with_element(|element| {
self.with_element_mut(|element| {
self.tree
.borrow_mut()
.borrow_mut()
.as_mut()
.unwrap()
.diff_children(std::slice::from_ref(&element));
.diff_children(std::slice::from_mut(element));
});
}
@ -279,7 +279,7 @@ where
vec![]
}
fn diff(&self, tree: &mut Tree) {
fn diff(&mut self, tree: &mut Tree) {
let tree = tree.state.downcast_ref::<Rc<RefCell<Option<Tree>>>>();
*self.tree.borrow_mut() = tree.clone();
self.rebuild_element_if_necessary();

View file

@ -82,7 +82,7 @@ where
let size = limits.max();
self.content = (self.view)(size);
state.tree.diff(&self.content);
state.tree.diff(&mut self.content);
self.content.as_widget_mut().layout(
&mut state.tree,