Include node ID when printing ChangeKind

pull/166/head
Wilfred Hughes 2022-03-13 18:28:33 +07:00
parent c0d1faae63
commit 0eb9f82aed
1 changed files with 13 additions and 7 deletions

@ -25,17 +25,23 @@ pub enum ChangeKind<'a> {
Novel,
}
/// A Debug implementation that ignores the corresponding node
/// mentioned for Unchanged. Otherwise we will infinitely loop on
/// unchanged nodes, which both point to the other.
/// A Debug implementation that does not reucurse into the
/// corresponding node mentioned for Unchanged. Otherwise we will
/// infinitely loop on unchanged nodes, which both point to the other.
impl<'a> fmt::Debug for ChangeKind<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let desc = match self {
Unchanged(_) => "Unchanged",
ReplacedComment(_, _) => "ReplacedComment",
Novel => "Novel",
Unchanged(node) => format!("Unchanged(ID: {})", node.id()),
ReplacedComment(lhs_node, rhs_node) => {
format!(
"ReplacedComment(lhs ID: {}, rhs ID: {})",
lhs_node.id(),
rhs_node.id()
)
}
Novel => "Novel".to_owned(),
};
f.write_str(desc)
f.write_str(&desc)
}
}