Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add impl for smol_str v0.2 #263

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions schemars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ rust_decimal = { version = "1", default-features = false, optional = true }
bigdecimal03 = { version = "0.3", default-features = false, optional = true, package = "bigdecimal" }
bigdecimal04 = { version = "0.4", default-features = false, optional = true, package = "bigdecimal" }
enumset = { version = "1.0", optional = true }
smol_str = { version = "0.1.17", optional = true }
smol_str01 = { package = "smol_str", version = "0.1.17", optional = true }
smol_str02 = { package = "smol_str", version = "0.2.1", optional = true }
semver = { version = "1.0.9", features = ["serde"], optional = true }

[dev-dependencies]
Expand All @@ -60,6 +61,8 @@ uuid = ["uuid08"]
# `arrayvec` feature without version suffix is included only for back-compat - will be removed in a later version
arrayvec = ["arrayvec05"]
indexmap1 = ["indexmap"]
# `smol_str` feature without version suffix is included only for back-compat - will be removed in a later version
smol_str = ["smol_str01"]

raw_value = ["serde_json/raw_value"]
# `bigdecimal` feature without version suffix is included only for back-compat - will be removed in a later version
Expand Down Expand Up @@ -116,8 +119,12 @@ name = "enumset"
required-features = ["enumset"]

[[test]]
name = "smol_str"
required-features = ["smol_str"]
name = "smol_str01"
required-features = ["smol_str01"]

[[test]]
name = "smol_str02"
required-features = ["smol_str02"]

[[test]]
name = "semver"
Expand Down
6 changes: 4 additions & 2 deletions schemars/src/json_schema_impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ mod sequences;
mod serdejson;
#[cfg(feature = "smallvec")]
mod smallvec;
#[cfg(feature = "smol_str")]
mod smol_str;
#[cfg(feature = "smol_str01")]
mod smol_str01;
#[cfg(feature = "smol_str02")]
mod smol_str02;
mod time;
mod tuple;
#[cfg(feature = "url")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::gen::SchemaGenerator;
use crate::schema::*;
use crate::JsonSchema;
use smol_str::SmolStr;
use smol_str01::SmolStr;

forward_impl!(SmolStr => String);
6 changes: 6 additions & 0 deletions schemars/src/json_schema_impls/smol_str02.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use crate::gen::SchemaGenerator;
use crate::schema::*;
use crate::JsonSchema;
use smol_str02::SmolStr;

forward_impl!(SmolStr => String);
5 changes: 5 additions & 0 deletions schemars/tests/expected/smol_str01.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "String",
"type": "string"
}
5 changes: 5 additions & 0 deletions schemars/tests/expected/smol_str02.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "String",
"type": "string"
}
8 changes: 0 additions & 8 deletions schemars/tests/smol_str.rs

This file was deleted.

8 changes: 8 additions & 0 deletions schemars/tests/smol_str01.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mod util;
use smol_str01::SmolStr;
use util::*;

#[test]
fn smol_str01() -> TestResult {
test_default_generated_schema::<SmolStr>("smol_str01")
}
8 changes: 8 additions & 0 deletions schemars/tests/smol_str02.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mod util;
use smol_str02::SmolStr;
use util::*;

#[test]
fn smol_str02() -> TestResult {
test_default_generated_schema::<SmolStr>("smol_str02")
}
Loading