Skip to content

Commit 9adc27f

Browse files
committed
🐛 Correctly implement Default
1 parent 7651a05 commit 9adc27f

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bitfield-struct"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
edition = "2021"
55
authors = ["Lars Wrenger <lars@wrenger.net>"]
66
description = "Procedural macro for bitfields."

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ fn bitfield_inner(args: TokenStream, input: TokenStream) -> syn::Result<TokenStr
302302
#( #members )*
303303
}
304304

305+
impl Default for #name {
306+
fn default() -> Self {
307+
Self::new()
308+
}
309+
}
310+
305311
impl From<#ty> for #name {
306312
fn from(v: #ty) -> Self {
307313
Self(v)

tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn members() {
8989
fn attrs() {
9090
/// We have a custom debug implementation -> opt out
9191
#[bitfield(u64)]
92-
#[derive(PartialEq, Eq, Default)]
92+
#[derive(PartialEq, Eq)]
9393
struct Full {
9494
data: u64,
9595
}

0 commit comments

Comments
 (0)