Skip to content

Commit

Permalink
Fix derivation of Serialize and Deserialize
Browse files Browse the repository at this point in the history
* Bitflags 2.0.0 now uses a newtype, so we want serde(transparent) to
  actually (de-)serialize the field of that newtype.
* We need to specify serde as a feature for Bitflags in Cargo.toml.
  • Loading branch information
michaellass committed Mar 14, 2023
1 parent 1f3cf35 commit 7907a7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ e2p-sys = { version= "0.1.0", git = "https://github.com/michaellass/e2p-sys.git"
bitflags = "^2.0.0"
e2p-sys = { version= "0.1.0", git = "https://github.com/michaellass/e2p-sys.git" }
serde = { version = "^1.0.115", optional = true, features = ["derive"] }

[features]
serde = ["dep:serde", "bitflags/serde"]
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use std::path::Path;

bitflags! {
#[derive(Copy, Clone, Debug, Default, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]
pub struct Flags: u32 {
const SECRM = EXT2_SECRM_FL;
const UNRM = EXT2_UNRM_FL;
Expand Down

0 comments on commit 7907a7e

Please sign in to comment.