Skip to content

Commit ab369e9

Browse files
committed
Add serde feature
1 parent e945ee7 commit ab369e9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "inline-str"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
authors = ["Adam Gutglick <adamgsal@gmail.com>"]
66
description = "Efficent and immutable string type, backed by inline-array"
@@ -13,3 +13,7 @@ categories = ["data-structures", "compression"]
1313

1414
[dependencies]
1515
inline-array = "0.1.13"
16+
serde = { version = "1.0", features = ["derive"], optional = true }
17+
18+
[features]
19+
serde = ["inline-array/serde", "dep:serde"]

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::{borrow::Cow, ops::Deref};
1818
use inline_array::InlineArray;
1919

2020
#[derive(PartialEq, Eq, PartialOrd, Ord)]
21+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2122
pub struct InlineStr {
2223
inner: InlineArray,
2324
}
@@ -86,19 +87,19 @@ impl<'a> PartialEq<&'a str> for InlineStr {
8687
}
8788
}
8889

89-
impl<'a> PartialEq<InlineStr> for &'a str {
90+
impl PartialEq<InlineStr> for &str {
9091
fn eq(&self, other: &InlineStr) -> bool {
9192
other.eq(self)
9293
}
9394
}
9495

95-
impl<'a> PartialEq<Cow<'a, str>> for InlineStr {
96-
fn eq(&self, other: &Cow<'a, str>) -> bool {
96+
impl PartialEq<Cow<'_, str>> for InlineStr {
97+
fn eq(&self, other: &Cow<'_, str>) -> bool {
9798
(**self).eq(other)
9899
}
99100
}
100101

101-
impl<'a> PartialEq<InlineStr> for Cow<'a, str> {
102+
impl PartialEq<InlineStr> for Cow<'_, str> {
102103
fn eq(&self, other: &InlineStr) -> bool {
103104
other.eq(self)
104105
}

0 commit comments

Comments
 (0)