Skip to content

Commit

Permalink
make Intern<str> work with serde (closes #49)
Browse files Browse the repository at this point in the history
  • Loading branch information
droundy committed Apr 21, 2024
1 parent b703a33 commit 1eb3a80
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* 0.8.3 - April 21, 2024

- Made `Intern<str>` work with `serde`.

* 0.8.2 - April 17, 2024

- Added support for `deepsize` for all three intern types.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "internment"
version = "0.8.2"
version = "0.8.3"
authors = ["David Roundy <[email protected]>"]
edition = "2018"

Expand Down
4 changes: 2 additions & 2 deletions src/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<T: Eq + Hash + Send + Sync + Ord + ?Sized> Ord for Intern<T> {

#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
#[cfg(feature = "serde")]
impl<T: Eq + Hash + Send + Sync + Serialize> Serialize for Intern<T> {
impl<T: Eq + Hash + Send + Sync + Serialize + ?Sized> Serialize for Intern<T> {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
self.as_ref().serialize(serializer)
}
Expand All @@ -409,7 +409,7 @@ impl<T: Eq + Hash + Send + Sync + Default + 'static> Default for Intern<T> {

#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
#[cfg(feature = "serde")]
impl<'de, T: Eq + Hash + Send + Sync + 'static + Deserialize<'de>> Deserialize<'de> for Intern<T> {
impl<'de, T: Eq + Hash + Send + Sync + ?Sized + 'static + Deserialize<'de>> Deserialize<'de> for Intern<T> {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
T::deserialize(deserializer).map(|x: T| Self::new(x))
}
Expand Down

0 comments on commit 1eb3a80

Please sign in to comment.