diff --git a/Cargo.toml b/Cargo.toml index 1864b23..27005d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,12 @@ repository = "https://github.com/cloudhead/nonempty" [dependencies] serde = { features = ["serde_derive"], optional = true, version = "1" } arbitrary = { features = ["derive"], optional = true, version = "1" } +bincode = { optional = true, version = "2.0.0-rc.3" } [features] serialize = ["serde"] arbitrary = ["dep:arbitrary"] +bincode2 = ["dep:bincode"] [dev-dependencies] serde_json = "1" diff --git a/src/lib.rs b/src/lib.rs index 6db4b07..4a9d3fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,8 +72,11 @@ //! //! * `serialize`: `serde` support. //! * `arbitrary`: `arbitrary` support. +//! * `bincode2`" `bincode@2.0.0-rc.3` support. #[cfg(feature = "arbitrary")] use arbitrary::Arbitrary; +#[cfg(feature = "bincode2")] +use bincode::{Decode, Encode}; #[cfg(feature = "serialize")] use serde::{ ser::{SerializeSeq, Serializer}, @@ -121,7 +124,15 @@ macro_rules! nonempty { /// Non-empty vector. #[cfg_attr(feature = "serialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[cfg_attr(feature = "bincode2", derive(Encode, Decode))] #[cfg_attr(feature = "serialize", serde(try_from = "Vec"))] +#[cfg_attr( + feature = "bincode2", + bincode( + encode_bounds = "T: Encode + 'static", + decode_bounds = "T: Decode + 'static", + ) +)] #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct NonEmpty { pub head: T,