From 720a12b7e640b8f4b1b072175afe585a190756f1 Mon Sep 17 00:00:00 2001 From: Woshiluo Luo Date: Wed, 6 Nov 2024 02:03:14 +0800 Subject: [PATCH] fix: wrong at item of NodeSeqItem Signed-off-by: Woshiluo Luo --- src/de_mut/node_seq.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/de_mut/node_seq.rs b/src/de_mut/node_seq.rs index 3b5a7b5..f3d1089 100644 --- a/src/de_mut/node_seq.rs +++ b/src/de_mut/node_seq.rs @@ -134,11 +134,15 @@ impl<'de> Iterator for NodeSeqIter<'de, '_> { match self.de.move_on() { // 子节点名字 Cursor::Title(c) => { - let (name, _) = c.split_on(self.de.dtb); - let (node, next) = c.take_node_on(self.de.dtb, name); - - let pre_len = name.as_bytes().iter().take_while(|b| **b != b'@').count(); - let name_bytes = &name.as_bytes()[..pre_len]; + let (full_name, _) = c.split_on(self.de.dtb); + let (node, next) = c.take_node_on(self.de.dtb, full_name); + + let pre_len = full_name + .as_bytes() + .iter() + .take_while(|b| **b != b'@') + .count(); + let name_bytes = &full_name.as_bytes()[..pre_len]; let name = unsafe { core::str::from_utf8_unchecked(name_bytes) }; if self.seq.name != name { return None; @@ -150,7 +154,7 @@ impl<'de> Iterator for NodeSeqIter<'de, '_> { dtb: self.de.dtb, reg: self.de.reg, body: node, - at: &name[pre_len..], + at: &full_name[pre_len + 1..], }) } _ => None,