Skip to content

Commit

Permalink
Fix cargo test without --all-features
Browse files Browse the repository at this point in the history
  • Loading branch information
mqudsi committed Apr 29, 2024
1 parent 6537ee3 commit 6453742
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/tweet.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
use serde::{Deserialize, Serialize};
use size::consts::*; // Import consts like KB, MiB, etc.
use size::Size; // Core type for all size operations
// Work around https://github.com/rust-lang/cargo/issues/9208
#[cfg(not(feature = "serde"))]
fn main() { panic!("Requisite feature is not enabled!") }

#[cfg(feature = "serde")]
fn main() {
use serde::{Deserialize, Serialize};
use size::consts::*; // Import consts like KB, MiB, etc.
use size::Size; // Core type for all size operations

// Flexible construction options
let s = Size::from_bytes(440 * KB) + Size::from_mib(12.9);
println!("The pretty file size {s}"); // 13.3 MiB
Expand Down

0 comments on commit 6453742

Please sign in to comment.