Skip to content

Commit 1b5f443

Browse files
ogoffarttronical
authored andcommitted
Better debug for the ItemRc
1 parent f484fba commit 1b5f443

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

internal/core/item_tree.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,22 @@ pub enum ParentItemTraversalMode {
269269

270270
/// A ItemRc is holding a reference to a ItemTree containing the item, and the index of this item
271271
#[repr(C)]
272-
#[derive(Clone, Debug)]
272+
#[derive(Clone)]
273273
pub struct ItemRc {
274274
item_tree: vtable::VRc<ItemTreeVTable>,
275275
index: u32,
276276
}
277277

278+
impl core::fmt::Debug for ItemRc {
279+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
280+
let comp_ref_pin = vtable::VRc::borrow_pin(&self.item_tree);
281+
let mut debug = SharedString::new();
282+
comp_ref_pin.as_ref().item_element_infos(self.index, &mut debug);
283+
284+
write!(f, "ItemRc{{ {:p}, {:?} {debug}}}", comp_ref_pin.as_ptr(), self.index)
285+
}
286+
}
287+
278288
impl ItemRc {
279289
/// Create an ItemRc from a ItemTree and an index
280290
pub fn new(item_tree: vtable::VRc<ItemTreeVTable>, index: u32) -> Self {

0 commit comments

Comments
 (0)