Skip to content

Commit caad491

Browse files
authored
Respect impl_arbitrary config when importing arbitrary
1 parent b14c392 commit caad491

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,16 @@ pub fn codegen(config: Config<'_>, out: impl Write) -> Result<()> {
149149
writeln!(&mut w, "use bitvec::prelude::*;")?;
150150
writeln!(&mut w, "use embedded_can::{{Id, StandardId, ExtendedId}};")?;
151151

152-
writeln!(w, r##"#[cfg(feature = "arb")]"##)?;
153-
writeln!(&mut w, "use arbitrary::{{Arbitrary, Unstructured}};")?;
152+
match config.impl_arbitrary {
153+
FeatureConfig::Always => {
154+
writeln!(&mut w, "use arbitrary::{{Arbitrary, Unstructured}};")?;
155+
}
156+
FeatureConfig::Gated(gate) => {
157+
writeln!(w, r##"#[cfg(feature = "{gate}")]"##)?;
158+
writeln!(&mut w, "use arbitrary::{{Arbitrary, Unstructured}};")?;
159+
}
160+
FeatureConfig::Never => (),
161+
}
154162

155163
match config.impl_serde {
156164
FeatureConfig::Always => {

0 commit comments

Comments
 (0)