Skip to content

Commit

Permalink
feat: remove derive feature from arbitrary support
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Feb 9, 2025
1 parent ffbc6ab commit b7e3ea6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
14 changes: 0 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ arbitrary = ["dep:arbitrary"]
serde = ["dep:serde"]

[dependencies]
arbitrary = { version = "1", features = ["derive"], optional = true }
arbitrary = { version = "1", optional = true }
serde = { version = "1", optional = true }

[dev-dependencies]
Expand Down
13 changes: 13 additions & 0 deletions src/arbitrary.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use arbitrary::{Arbitrary, Unstructured};

use crate::ByteSize;

impl Arbitrary<'_> for ByteSize {
fn arbitrary(u: &mut Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(ByteSize(u64::arbitrary(u)?))
}

fn size_hint(depth: usize) -> (usize, Option<usize>) {
u64::size_hint(depth)
}
}
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
//! assert_eq!("518.0 GB", ByteSize::gb(518).to_string_as(false));
//! ```
#[cfg(feature = "arbitrary")]
mod arbitrary;
mod parse;
#[cfg(feature = "serde")]
mod serde;
Expand Down Expand Up @@ -105,7 +107,6 @@ pub fn pib<V: Into<u64>>(size: V) -> u64 {

/// Byte size representation
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Default)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct ByteSize(pub u64);

impl ByteSize {
Expand Down

0 comments on commit b7e3ea6

Please sign in to comment.