Skip to content

Commit baaa129

Browse files
committed
impl Debug for I2cdev
1 parent 1ffb268 commit baaa129

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/i2c.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ impl I2cdev {
4242
}
4343
}
4444

45+
impl fmt::Debug for I2cdev {
46+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
47+
f.debug_struct("I2cdev")
48+
.field("path", &self.path)
49+
.field("address", &self.address)
50+
// For the inner field we provide a placeholder, i2cdev does not impl Debug for LinuxI2CDevice
51+
.field("inner", &format!("LinuxI2CDevice<path: {:?}>", self.path))
52+
.finish()
53+
}
54+
}
55+
4556
impl ops::Deref for I2cdev {
4657
type Target = i2cdev::linux::LinuxI2CDevice;
4758

0 commit comments

Comments
 (0)