From 1c4383e7fe757f9351db294b3ada3c05ecdf1f81 Mon Sep 17 00:00:00 2001 From: matt rice Date: Mon, 17 Mar 2025 10:51:14 -0700 Subject: [PATCH] Add optional bincode dependency --- Cargo.toml | 9 +++++++-- src/lib.rs | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 88e16c3..5f7681b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,15 @@ readme = "README.md" license = "Apache-2.0/MIT" categories = ["data-structures"] +[features] +bincode = ["dep:bincode", "vob/bincode", "packedvec/bincode"] +serde = ["dep:serde", "vob/serde", "packedvec/serde"] + [dependencies] -vob = { version=">=3.0.2", features=["serde"] } -packedvec = { version="1.0", features=["serde"] } +vob = { version="3.0.4" } +packedvec = { version="1.2.5" } serde = { version="1.0", features=["derive"], optional=true } +bincode = { version="2.0", features=["derive"], optional=true } num-traits = "0.2" [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index e0d2963..08bb460 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ #![allow(clippy::many_single_char_names)] +#[cfg(feature = "bincode")] +use bincode::{Decode, Encode}; use num_traits::{AsPrimitive, FromPrimitive, PrimInt, ToPrimitive, Unsigned}; use packedvec::PackedVec; #[cfg(feature = "serde")] @@ -60,6 +62,7 @@ use vob::Vob; /// value = c[pos] // =3 /// ``` #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "bincode", derive(Encode, Decode))] #[derive(Debug)] pub struct SparseVec { displacement: Vec, // Displacement vector