Skip to content

Commit 7f50fe0

Browse files
author
Thom Chiovoloni
committed
Make serde dependency optional, but enabled by default
1 parent 86a33eb commit 7f50fe0

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ rust:
88
os:
99
- linux
1010
script:
11+
- cargo build --no-default-features
1112
- cargo build
1213
- cargo test --all
1314
- "cd string-cache-codegen && cargo build && cd .."

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ edition = "2018"
1717
[lib]
1818
name = "string_cache"
1919

20+
[features]
21+
serde_support = ["serde"]
22+
default = ["serde_support"]
23+
2024
[dependencies]
2125
precomputed-hash = "0.1"
2226
lazy_static = "1"
23-
serde = "1"
27+
serde = { version = "1", optional = true }
2428
phf_shared = "0.8"
2529
new_debug_unreachable = "1.0"
2630

src/trivial_impls.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// except according to those terms.
99

1010
use crate::{Atom, StaticAtomSet};
11+
#[cfg(feature = "serde_support")]
1112
use serde::{Deserialize, Deserializer, Serialize, Serializer};
1213
use std::borrow::Cow;
1314
use std::fmt;
@@ -69,6 +70,7 @@ impl<Static: StaticAtomSet> AsRef<str> for Atom<Static> {
6970
}
7071
}
7172

73+
#[cfg(feature = "serde_support")]
7274
impl<Static: StaticAtomSet> Serialize for Atom<Static> {
7375
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
7476
where
@@ -79,6 +81,7 @@ impl<Static: StaticAtomSet> Serialize for Atom<Static> {
7981
}
8082
}
8183

84+
#[cfg(feature = "serde_support")]
8285
impl<'a, Static: StaticAtomSet> Deserialize<'a> for Atom<Static> {
8386
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
8487
where

0 commit comments

Comments
 (0)