Skip to content

Commit

Permalink
Merge pull request #42 from dzmitry-lahoda-forks/dz/1
Browse files Browse the repository at this point in the history
feat(serde): borsh
  • Loading branch information
isaacholt100 authored Jul 3, 2024
2 parents bc00364 + 6f12379 commit b1116da
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
- name: Install latest stable Rust
run: rustup install stable
- name: Check crate builds on stable
run: cargo build --features serde,numtraits,rand,arbitrary && cargo build
# NOTE: consider using https://github.com/frewsxcv/cargo-all-features, because all features != their arbitrary combinations
run: cargo build --features serde,numtraits,rand,arbitrary,borsh && cargo build
test_nightly:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ default = []
nightly = []
serde = ["dep:serde", "serde-big-array"]
numtraits = ["num-integer", "num-traits"]
borsh = ["dep:borsh"]

[dependencies]
num-integer = { version = "0.1", optional = true, default-features = false }
Expand All @@ -33,6 +34,7 @@ quickcheck = { version = "1.0", optional = true, default-features = false }
# proptest = { version = "1.2", optional = true, default-features = false }
valuable = { version = "0.1", optional = true, features = ["derive"], default-features = false }
# lit-parser = { path = "./lit-parser/", optional = true }
borsh = { version = "^1.5", optional = true, default-features = false, features = ["rc", "std", "unstable__schema"]}

[dev-dependencies]
quickcheck = "1.0"
Expand Down
7 changes: 7 additions & 0 deletions src/bint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ use crate::{doc, errors};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[cfg(feature = "borsh")]
use ::{
alloc::string::ToString,
borsh::{BorshDeserialize, BorshSchema, BorshSerialize},
};

use core::default::Default;

use core::iter::{Iterator, Product, Sum};
Expand All @@ -46,6 +52,7 @@ macro_rules! mod_impl {

#[derive(Clone, Copy, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize, BorshSchema))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "valuable", derive(valuable::Valuable))]
#[repr(transparent)]
Expand Down
7 changes: 7 additions & 0 deletions src/buint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ use ::{
serde_big_array::BigArray,
};

#[cfg(feature = "borsh")]
use ::{
alloc::string::ToString,
borsh::{BorshDeserialize, BorshSchema, BorshSerialize},
};

use core::default::Default;

use core::iter::{Iterator, Product, Sum};
Expand All @@ -29,6 +35,7 @@ macro_rules! mod_impl {

#[derive(Clone, Copy, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize, BorshSchema))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "valuable", derive(valuable::Valuable))]
#[repr(transparent)]
Expand Down

0 comments on commit b1116da

Please sign in to comment.