Skip to content

Commit 3b8e9ac

Browse files
committed
Function name tweak
1 parent bb0f31b commit 3b8e9ac

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/collapse/xctrace.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct BacktraceOccurrences {
4444
backtrace: Arc<Backtrace>,
4545
}
4646

47-
/// Backtrace of scanning xml tags.
47+
/// Backtrace of scanned xml tags.
4848
#[derive(Default)]
4949
struct TagBacktrace {
5050
backtrace: Vec<CurrentTag>,
@@ -55,18 +55,18 @@ impl TagBacktrace {
5555
self.backtrace.push(tag);
5656
}
5757

58-
/// Remove the top tag and return it. Return `Err(())` on tag mismatching.
59-
fn collide(&mut self, name: &[u8]) -> Result<CurrentTag, ()> {
58+
/// If `name` matches the top tag of the stack, the tag is popped.
59+
fn pop_with_name(&mut self, name: &[u8]) -> Option<CurrentTag> {
6060
if self
6161
.backtrace
6262
.last()
6363
.map(|t| t.matches(name))
6464
.unwrap_or_default()
6565
{
6666
// There is at least one element in backtrace, hence this unwrap is safe.
67-
Ok(self.backtrace.pop().unwrap())
67+
Some(self.backtrace.pop().unwrap())
6868
} else {
69-
Err(())
69+
None
7070
}
7171
}
7272

@@ -309,7 +309,7 @@ impl Folder {
309309
}
310310
Event::End(end) => {
311311
let name = end.name().into_inner();
312-
let state = match context.state_backtrace.collide(name) {
312+
let state = match context.state_backtrace.pop_with_name(name) {
313313
Ok(state) => state,
314314
Err(()) => {
315315
return invalid_data_error!(

0 commit comments

Comments
 (0)