Skip to content

Commit

Permalink
Add optional borsh serialisation support
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuuzetsu authored and pczarn committed May 31, 2024
1 parent 1bc71c9 commit 31a80b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ keywords = ["data-structures", "bitvec", "bitmask", "bitmap", "bit"]
readme = "README.md"

[dependencies]
borsh = { version = "1.2.0", default-features = false, features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }

[dev-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ use std::vec::Vec;
extern crate serde;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "borsh")]
extern crate borsh;

#[cfg(not(feature = "std"))]
#[macro_use]
Expand Down Expand Up @@ -218,6 +220,10 @@ static FALSE: bool = false;
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
/// ```
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(
feature = "borsh",
derive(borsh::BorshDeserialize, borsh::BorshSerialize)
)]
pub struct BitVec<B = u32> {
/// Internal representation of the bit vector
storage: Vec<B>,
Expand Down

0 comments on commit 31a80b9

Please sign in to comment.