Update code with rustfmt
@@ -12,7 +12,10 @@ use defmt_semihosting as _; // global logger
#[entry]
fn main() -> ! {
{
- struct S1 { x: &'static str, y: u8 }
+ struct S1 {
+ x: &'static str,
+ y: u8,
+ }
impl defmt::Format for S1 {
fn format(&self, f: defmt::Formatter) {
write!(f, "S1 {{ x: {=str:?}, y: {=u8:?} }}", self.x, self.y)
@@ -24,7 +27,9 @@ fn main() -> ! {
}
{
- struct S2 { x: u8 }
+ struct S2 {
+ x: u8,
+ }
impl defmt::Format for S2 {
fn format(&self, f: defmt::Formatter) {
write!(f, "S2 {{ x: {=u8:x} }}", self.x)
@@ -37,34 +42,73 @@ fn main() -> ! {
{
#[derive(defmt::Format)]
- struct S { x: &'static str, y: u32 }
+ struct S {
+ x: &'static str,
+ y: u32,
+ }
// 0.1.x version
defmt::warn!("Debug hint: {:?}", S { x: "hello", y: 512 });
// 0.2.x version, results in same output
- defmt::warn!(" no hint: {}", S { x: "hello", y: 1024 });
+ defmt::warn!(
+ " no hint: {}",
+ S {
+ x: "hello",
+ y: 1024
+ }
+ );
}
{
// nested struct
- struct S1 { x: u16, y: u32 }
+ struct S1 {
+ x: u16,
+ y: u32,
+ }
impl defmt::Format for S1 {
fn format(&self, f: defmt::Formatter) {
write!(f, "S1 {{ x: {=u16:b}, y: {} }}", self.x, self.y);
}
}
- struct S2 { s: S1, z: u8 }
+ struct S2 {
+ s: S1,
+ z: u8,
+ }
impl defmt::Format for S2 {
fn format(&self, f: defmt::Formatter) {
write!(f, "S2 {{ s: {:?}, z: {} }}", self.s, self.z);
}
}
- defmt::info!("{}", S2 { s: S1 { x: 4, y: 12 }, z: 20 });
- defmt::info!("{:?}", S2 { s: S1 { x: 4, y: 12 }, z: 20 });
- defmt::info!("{:x}", S2 { s: S1 { x: 4, y: 12 }, z: 20 });
- defmt::info!("{:b}", S2 { s: S1 { x: 4, y: 12 }, z: 20 });
+ defmt::info!(
+ "{}",
+ S2 {
+ s: S1 { x: 4, y: 12 },
+ z: 20
+ }
+ );
+ defmt::info!(
+ "{:?}",
+ S2 {
+ s: S1 { x: 4, y: 12 },
+ z: 20
+ }
+ );
+ defmt::info!(
+ "{:x}",
+ S2 {
+ s: S1 { x: 4, y: 12 },
+ z: 20
+ }
+ );
+ defmt::info!(
+ "{:b}",
+ S2 {
+ s: S1 { x: 4, y: 12 },
+ z: 20
+ }
+ );
}
loop {
