Skip to content

Commit

Permalink
chore(cargo): add serde compact optional split
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Dec 23, 2023
1 parent da910f9 commit 2cf9356
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "case_insensitive_string"
version = "0.1.7"
version = "0.2.0"
authors = ["Jeff Mendez <[email protected]>"]
edition = "2021"
description = "A case insensitive string struct."
Expand All @@ -12,8 +12,9 @@ categories = ["config", "data-structures"]
include = ["src/*", "LICENSE", "README.md"]

[dependencies]
compact_str = { version = "0.7.0", optional = true }
serde = { version = "^1.0.155", optional = true, features = ["derive"] }
compact_str = { version = "0.7.1", optional = true }
serde = { version = "^1.0.193", optional = true, features = ["derive"] }

[features]
compact = [ "compact_str", "serde" ]
compact = ["dep:compact_str"]
serde = ["dep:serde"]
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ impl From<&str> for CaseInsensitiveString {
}
}

#[cfg(feature = "compact")]
impl From<compact_str::CompactString> for CaseInsensitiveString {
#[inline]
fn from(s: compact_str::CompactString) -> Self {
CaseInsensitiveString { 0: s.into() }
}
}

impl From<String> for CaseInsensitiveString {
fn from(s: String) -> Self {
CaseInsensitiveString { 0: s.into() }
Expand Down

0 comments on commit 2cf9356

Please sign in to comment.