Skip to content

Commit 6453742

Browse files
committed
Fix cargo test without --all-features
Work around rust-lang/cargo#9208
1 parent 6537ee3 commit 6453742

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/tweet.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
use serde::{Deserialize, Serialize};
2-
use size::consts::*; // Import consts like KB, MiB, etc.
3-
use size::Size; // Core type for all size operations
1+
// Work around https://github.com/rust-lang/cargo/issues/9208
2+
#[cfg(not(feature = "serde"))]
3+
fn main() { panic!("Requisite feature is not enabled!") }
44

5+
#[cfg(feature = "serde")]
56
fn main() {
7+
use serde::{Deserialize, Serialize};
8+
use size::consts::*; // Import consts like KB, MiB, etc.
9+
use size::Size; // Core type for all size operations
10+
611
// Flexible construction options
712
let s = Size::from_bytes(440 * KB) + Size::from_mib(12.9);
813
println!("The pretty file size {s}"); // 13.3 MiB

0 commit comments

Comments
 (0)