add support for compact_str crate

This commit is contained in:
Aleksandr 2025-01-18 15:26:47 +03:00
parent efb74969e2
commit 0b5abbcd0f
5 changed files with 35 additions and 1 deletions

18
Cargo.lock generated
View file

@ -191,6 +191,21 @@ dependencies = [
"static_assertions",
]
[[package]]
name = "compact_str"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b79c4069c6cad78e2e0cdfcbd26275770669fb39fd308a752dc110e83b9af32"
dependencies = [
"castaway",
"cfg-if",
"itoa",
"rustversion",
"ryu",
"serde",
"static_assertions",
]
[[package]]
name = "darling"
version = "0.20.10"
@ -326,7 +341,7 @@ version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a989bd2fd12136080f7825ff410d9239ce84a2a639487fc9d924ee42e2fb84f"
dependencies = [
"compact_str",
"compact_str 0.7.1",
"garde_derive",
"once_cell",
"regex",
@ -837,6 +852,7 @@ dependencies = [
"bigdecimal",
"bytes",
"chrono",
"compact_str 0.8.1",
"dyn-clone",
"either",
"garde",

View file

@ -32,6 +32,7 @@ smallvec1 = { version = "1.0", default-features = false, optional = true, packag
smol_str02 = { version = "0.2.1", default-features = false, optional = true, package = "smol_str" }
url2 = { version = "2.0", default-features = false, optional = true, package = "url" }
uuid1 = { version = "1.0", default-features = false, optional = true, package = "uuid" }
compact_str08 = { version = "0.8", default-features = false, optional = true, package = "compact_str" }
[dev-dependencies]
pretty_assertions = "1.2.1"
@ -54,6 +55,7 @@ rust_decimal1 = { version = "1", default-features = false, features = ["serde"],
semver1 = { version = "1.0.9", default-features = false, features = ["serde"], package = "semver" }
smallvec1 = { version = "1.0", default-features = false, features = ["serde"], package = "smallvec" }
smol_str02 = { version = "0.2.1", default-features = false, features = ["serde"], package = "smol_str" }
compact_str08 = { version = "0.8", default-features = false, features = ["serde"], package = "compact_str" }
url2 = { version = "2.0", default-features = false, features = ["serde"], package = "url" }
uuid1 = { version = "1.0", default-features = false, features = ["serde"], package = "uuid" }

View file

@ -83,6 +83,9 @@ forward_impl!((<A: smallvec1::Array> crate::JsonSchema for smallvec1::SmallVec<A
#[cfg(feature = "smol_str02")]
forward_impl!(smol_str02::SmolStr => alloc::string::String);
#[cfg(feature = "compact_str08")]
forward_impl!(compact_str08::CompactString => alloc::string::String);
#[cfg(feature = "url2")]
mod url2;

View file

@ -0,0 +1,11 @@
use compact_str08::CompactString;
use crate::prelude::*;
#[test]
fn compact_str() {
test!(CompactString)
.assert_identical::<String>()
.assert_allows_ser_roundtrip(["".into(), "test".into()])
.assert_matches_de_roundtrip(arbitrary_values());
}

View file

@ -41,6 +41,8 @@ mod skip;
mod smallvec;
#[cfg(feature = "smol_str02")]
mod smol_str;
#[cfg(feature = "compact_str08")]
mod compact_str;
mod std_types;
mod structs;
mod transform;