Commit c15f8ecd authored by Benjamin Woodruff's avatar Benjamin Woodruff

Fix type bound on Default

parent 17719924
...@@ -33,9 +33,7 @@ use serde::{Deserialize, Serialize}; ...@@ -33,9 +33,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// There are a variety of constructors provided that can be more efficient if you know that your /// There are a variety of constructors provided that can be more efficient if you know that your
/// data is sorted and/or unique. /// data is sorted and/or unique.
#[derive( #[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Encode, Decode, Serialize, Deserialize)]
Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord, Encode, Decode, Serialize, Deserialize,
)]
#[rustfmt::skip] // rustfmt breaks bincode's proc macro string processing #[rustfmt::skip] // rustfmt breaks bincode's proc macro string processing
#[bincode( #[bincode(
decode_bounds = "K: Decode<__Context> + 'static, V: Decode<__Context> + 'static", decode_bounds = "K: Decode<__Context> + 'static, V: Decode<__Context> + 'static",
...@@ -509,6 +507,13 @@ impl<K, V> FrozenMap<K, V> { ...@@ -509,6 +507,13 @@ impl<K, V> FrozenMap<K, V> {
} }
} }
// Manual implementation because the derive would add unnecessary `K: Default, V: Default` bounds.
impl<K, V> Default for FrozenMap<K, V> {
fn default() -> Self {
Self::new()
}
}
impl<K: Debug, V: Debug> Debug for FrozenMap<K, V> { impl<K: Debug, V: Debug> Debug for FrozenMap<K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_map().entries(self.iter()).finish() f.debug_map().entries(self.iter()).finish()
......
...@@ -38,9 +38,7 @@ use crate::map::{self, FrozenMap}; ...@@ -38,9 +38,7 @@ use crate::map::{self, FrozenMap};
/// [`Vec`] or boxed slice. Because of limitations of the internal representation and Rust's memory /// [`Vec`] or boxed slice. Because of limitations of the internal representation and Rust's memory
/// layout rules, the most efficient way to convert from these data structures is via an /// layout rules, the most efficient way to convert from these data structures is via an
/// [`Iterator`]. /// [`Iterator`].
#[derive( #[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Encode, Decode, Serialize, Deserialize)]
Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord, Encode, Decode, Serialize, Deserialize,
)]
#[bincode( #[bincode(
decode_bounds = "T: Decode<__Context> + 'static", decode_bounds = "T: Decode<__Context> + 'static",
borrow_decode_bounds = "T: BorrowDecode<'__de, __Context> + '__de" borrow_decode_bounds = "T: BorrowDecode<'__de, __Context> + '__de"
...@@ -308,6 +306,13 @@ impl<T> FrozenSet<T> { ...@@ -308,6 +306,13 @@ impl<T> FrozenSet<T> {
} }
} }
// Manual implementation because the derive would add unnecessary `T: Default` bounds.
impl<T> Default for FrozenSet<T> {
fn default() -> Self {
Self::new()
}
}
impl<T: Debug> Debug for FrozenSet<T> { impl<T: Debug> Debug for FrozenSet<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_set().entries(self.iter()).finish() f.debug_set().entries(self.iter()).finish()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment