Procházet zdrojové kódy

Add way to pretty-print individual nodes (#21)

* Fix formatting

* Fix failing test

I think this was affected from changes in commit 2319fd3374

* Add way to pretty-print individual nodes
Dagan Martinez před 1 rokem
rodič
revize
6fc87b53da
1 změnil soubory, kde provedl 8 přidání a 0 odebrání
  1. 8 0
      src/node.rs

+ 8 - 0
src/node.rs

@@ -39,6 +39,14 @@ pub struct FdtNode<'b, 'a: 'b> {
     parent_props: Option<&'a [u8]>,
 }
 
+#[cfg(feature = "pretty-printing")]
+impl core::fmt::Display for FdtNode<'_, '_> {
+    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+        crate::pretty_print::print_node(f, *self, 0)?;
+        Ok(())
+    }
+}
+
 impl<'b, 'a: 'b> FdtNode<'b, 'a> {
     fn new(
         name: &'a str,