diff --git a/src/header.rs b/src/header.rs index 186928e6fb069d255f3358224ce22fee80e572b9..29876a7860dc97be3cc22114eb032a86c9811b46 100644 --- a/src/header.rs +++ b/src/header.rs @@ -157,23 +157,17 @@ impl Default for Header { impl fmt::Debug for Header { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let signature = self.signature; - let version = self.version; - let uuid = self.uuid; - let size = self.size; - let generation = self.generation; - let tree = self.tree; - let alloc = self.alloc; - let hash = self.hash; + // the braces are to make the arguments get passed as temporaries, + // instead of unaligned references into the packed struct f.debug_struct("Header") - .field("signature", &signature) - .field("version", &version) - .field("uuid", &uuid) - .field("size", &size) - .field("generation", &generation) - .field("tree", &tree) - .field("alloc", &alloc) - .field("hash", &hash) + .field("signature", &{ self.signature }) + .field("version", &{ self.version }) + .field("uuid", &{ self.uuid }) + .field("size", &{ self.size }) + .field("generation", &{ self.generation }) + .field("tree", &{ self.tree }) + .field("alloc", &{ self.alloc }) + .field("hash", &{ self.hash }) .finish() } } diff --git a/src/node.rs b/src/node.rs index c675be277eb40967373d9d2706fc27fb8c78f4fa..52299d5f15e0fe68e602cc5d02ef3bb5e33817f2 100644 --- a/src/node.rs +++ b/src/node.rs @@ -259,29 +259,20 @@ impl Node { impl fmt::Debug for Node { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let mode = self.mode; - let uid = self.uid; - let gid = self.gid; - let links = self.links; - let size = self.size; - let ctime = self.ctime; - let ctime_nsec = self.ctime_nsec; - let mtime = self.mtime; - let mtime_nsec = self.mtime_nsec; - let atime = self.atime; - let atime_nsec = self.atime_nsec; + // the braces are to make the arguments get passed as temporaries, + // instead of unaligned references into the packed struct f.debug_struct("Node") - .field("mode", &mode) - .field("uid", &uid) - .field("gid", &gid) - .field("links", &links) - .field("size", &size) - .field("ctime", &ctime) - .field("ctime_nsec", &ctime_nsec) - .field("mtime", &mtime) - .field("mtime_nsec", &mtime_nsec) - .field("atime", &atime) - .field("atime_nsec", &atime_nsec) + .field("mode", &{ self.mode }) + .field("uid", &{ self.uid }) + .field("gid", &{ self.gid }) + .field("links", &{ self.links }) + .field("size", &{ self.size }) + .field("ctime", &{ self.ctime }) + .field("ctime_nsec", &{ self.ctime_nsec }) + .field("mtime", &{ self.mtime }) + .field("mtime_nsec", &{ self.mtime_nsec }) + .field("atime", &{ self.atime }) + .field("atime_nsec", &{ self.atime_nsec }) //TODO: level0/1/2/3 .finish() }