Remove macro impl_rare_data (#36771)

This macro does not hide any complex or unsafe implementation details,
and, it's only used in two files (node.rs and element.rs). This patch
removes the macro, and move the implementation in place.

Moreover, the Element::rare_data_mut function in element.rs is called by
other functions, so the #[allow(dead_code)] annotation is removed. The
Node::rare_data_mut function in node.rs is not called anywhere, so it is
removed.

Testing: No test is needed for this cleaning up.
Fixes: #36767

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This commit is contained in:
Kingsley Yung 2025-04-30 23:19:30 +08:00 committed by GitHub
parent c98cf8b306
commit 5c5da6071e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 25 deletions

View file

@ -327,7 +327,21 @@ impl Element {
)
}
impl_rare_data!(ElementRareData);
fn rare_data(&self) -> Ref<Option<Box<ElementRareData>>> {
self.rare_data.borrow()
}
fn rare_data_mut(&self) -> RefMut<Option<Box<ElementRareData>>> {
self.rare_data.borrow_mut()
}
fn ensure_rare_data(&self) -> RefMut<Box<ElementRareData>> {
let mut rare_data = self.rare_data.borrow_mut();
if rare_data.is_none() {
*rare_data = Some(Default::default());
}
RefMut::map(rare_data, |rare_data| rare_data.as_mut().unwrap())
}
pub(crate) fn restyle(&self, damage: NodeDamage) {
let doc = self.node.owner_doc();