You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Hint: You can use the rust-analyzer "Expand macro recursively" action to view the generated code.
190
190
191
-
## `fmt::Debug`
192
191
193
-
This macro automatically creates a suitable `fmt::Debug` implementation
194
-
similar to the ones created for normal structs by `#[derive(Debug)]`.
195
-
You can disable it with the extra debug argument.
192
+
## `fmt::Debug` and `Default`
196
193
197
-
```rust
198
-
#[bitfield(u64, debug = false)]
194
+
This macro automatically creates a suitable `fmt::Debug` and `Default` implementations similar to the ones created for normal structs by `#[derive(Debug, Default)]`.
195
+
You can disable this with the extra `debug` and `default` arguments.
196
+
197
+
```rs
198
+
#[bitfield(u64, debug = false, default = false)]
199
199
structCustomDebug {
200
200
data:u64
201
201
}
@@ -204,7 +204,12 @@ impl fmt::Debug for CustomDebug {
204
204
write!(f, "0x{:x}", self.data())
205
205
}
206
206
}
207
+
implDefaultforCustomDebug {
208
+
fndefault() ->Self {
209
+
Self(123) // note: you can also use `#[bits(64, default = 123)]`
0 commit comments