Skip to content

Commit

Permalink
Merge pull request #83 from inomotech-foss/fix-arb-gate
Browse files Browse the repository at this point in the history
Respect impl_arbitrary config when importing arbitrary
  • Loading branch information
Pascal Hertleif authored Aug 28, 2024
2 parents b14c392 + 3f69061 commit 6283aa4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
17 changes: 0 additions & 17 deletions src/includes/arbitrary_helpers.rs

This file was deleted.

18 changes: 6 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,13 @@ pub fn codegen(config: Config<'_>, out: impl Write) -> Result<()> {
writeln!(&mut w, "use bitvec::prelude::*;")?;
writeln!(&mut w, "use embedded_can::{{Id, StandardId, ExtendedId}};")?;

writeln!(w, r##"#[cfg(feature = "arb")]"##)?;
writeln!(&mut w, "use arbitrary::{{Arbitrary, Unstructured}};")?;
config.impl_arbitrary.fmt_cfg(&mut w, |w| {
writeln!(w, "use arbitrary::{{Arbitrary, Unstructured}};")
})?;

match config.impl_serde {
FeatureConfig::Always => {
writeln!(&mut w, "use serde::{{Serialize, Deserialize}};")?;
}
FeatureConfig::Gated(gate) => {
writeln!(w, r##"#[cfg(feature = "{gate}")]"##)?;
writeln!(&mut w, "use serde::{{Serialize, Deserialize}};")?;
}
FeatureConfig::Never => (),
}
config.impl_serde.fmt_cfg(&mut w, |w| {
writeln!(w, "use serde::{{Serialize, Deserialize}};")
})?;

writeln!(&mut w)?;

Expand Down

0 comments on commit 6283aa4

Please sign in to comment.