Compare commits

...

2 commits

Author SHA1 Message Date
cd26406fa9 feat: support hashbrown015 2025-02-15 23:01:42 +03:00
52a67fff57 add support for compact_str crate 2025-01-18 15:26:47 +03:00
5 changed files with 51 additions and 2 deletions

30
Cargo.lock generated
View file

@ -201,6 +201,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"
@ -313,7 +328,7 @@ name = "garde"
version = "0.20.0"
source = "git+https://github.com/jprochazk/garde.git?rev=be00ddddf8de14530ee890ccfdbaf0b13fb32852#be00ddddf8de14530ee890ccfdbaf0b13fb32852"
dependencies = [
"compact_str",
"compact_str 0.7.1",
"garde_derive",
"once_cell",
"regex",
@ -357,6 +372,15 @@ version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
[[package]]
name = "hashbrown"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
dependencies = [
"serde",
]
[[package]]
name = "ident_case"
version = "1.0.1"
@ -380,7 +404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5"
dependencies = [
"equivalent",
"hashbrown",
"hashbrown 0.14.5",
"serde",
]
@ -777,9 +801,11 @@ dependencies = [
"bigdecimal",
"bytes",
"chrono",
"compact_str 0.8.1",
"dyn-clone",
"either",
"garde",
"hashbrown 0.15.2",
"indexmap",
"jsonschema",
"pretty_assertions",

View file

@ -20,6 +20,7 @@ dyn-clone = "1.0"
ref-cast = "1.0.22"
# optional dependencies
hashbrown015 = { version = "0.15", default-features = false, optional = true, package = "hashbrown" }
arrayvec07 = { version = "0.7", default-features = false, optional = true, package = "arrayvec" }
bigdecimal04 = { version = "0.4", default-features = false, optional = true, package = "bigdecimal" }
bytes1 = { version = "1.0", default-features = false, optional = true, package = "bytes" }
@ -32,6 +33,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"
@ -45,6 +47,7 @@ garde = { git = "https://github.com/jprochazk/garde.git", rev = "be00ddddf8de145
validator = { version = "0.18.1", features = ["derive"] }
regex = { version = "1.10.6", default-features = false }
hashbrown015 = { version = "0.15", default-features = false, features = ["serde"], package = "hashbrown" }
arrayvec07 = { version = "0.7", default-features = false, features = ["serde"], package = "arrayvec"}
bigdecimal04 = { version = "0.4", default-features = false, features = ["serde"], package = "bigdecimal" }
bytes1 = { version = "1.0", default-features = false, features = ["serde"], package = "bytes" }
@ -55,6 +58,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,12 @@ 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 = "hashbrown015")]
forward_impl!((<K: crate::JsonSchema, V: crate::JsonSchema> crate::JsonSchema for hashbrown015::HashMap<K, V>) => std::collections::HashMap<K, V>);
#[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;