From 58cc7fac253b1ef510f9ac9a7d8c6af1d4ae09a3 Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Sun, 29 Dec 2019 22:09:54 +0000 Subject: [PATCH] Run cargo fmt --- README.md | 12 ++++-------- .../_includes/examples/custom_serialization.rs | 4 +++- docs/_includes/examples/doc_comments.rs | 4 ++-- docs/_includes/examples/main.rs | 6 ++---- docs/_includes/examples/remote_derive.rs | 2 +- docs/_includes/examples/schemars_attrs.rs | 6 ++---- docs/_includes/examples/serde_attrs.rs | 6 ++---- schemars/examples/custom_serialization.rs | 4 +++- schemars/examples/doc_comments.rs | 4 ++-- schemars/examples/main.rs | 6 ++---- schemars/examples/remote_derive.rs | 2 +- schemars/examples/schemars_attrs.rs | 6 ++---- schemars/examples/serde_attrs.rs | 6 ++---- schemars/src/gen.rs | 2 +- schemars/src/json_schema_impls/arrayvec.rs | 6 +++++- schemars/src/json_schema_impls/maps.rs | 3 +-- schemars/src/json_schema_impls/mod.rs | 18 +++++++++--------- schemars/src/lib.rs | 12 ++++-------- schemars/tests/arrayvec.rs | 4 ++-- schemars/tests/remote_derive_generic.rs | 4 ++-- schemars/tests/uuid.rs | 2 +- schemars_derive/src/lib.rs | 12 ++++-------- 22 files changed, 57 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index 28d375c..d612797 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,9 @@ pub struct MyStruct { } #[derive(JsonSchema)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { @@ -131,11 +129,9 @@ pub struct MyStruct { #[derive(Deserialize, Serialize, JsonSchema)] #[serde(untagged)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { diff --git a/docs/_includes/examples/custom_serialization.rs b/docs/_includes/examples/custom_serialization.rs index 2fc8fa9..9429bc3 100644 --- a/docs/_includes/examples/custom_serialization.rs +++ b/docs/_includes/examples/custom_serialization.rs @@ -38,7 +38,9 @@ mod as_string { D: Deserializer<'de>, { let string = String::deserialize(deserializer)?; - string.parse().map_err(|_| D::Error::custom("Input was not valid")) + string + .parse() + .map_err(|_| D::Error::custom("Input was not valid")) } } diff --git a/docs/_includes/examples/doc_comments.rs b/docs/_includes/examples/doc_comments.rs index 79ecc88..c3faa4f 100644 --- a/docs/_includes/examples/doc_comments.rs +++ b/docs/_includes/examples/doc_comments.rs @@ -16,7 +16,7 @@ pub struct MyStruct { /// # My Amazing Enum #[derive(JsonSchema)] -pub enum MyEnum { +pub enum MyEnum { /// A wrapper around a `String` StringNewType(String), /// A struct-like enum variant which contains @@ -24,7 +24,7 @@ pub enum MyEnum { StructVariant { /// The floats themselves floats: Vec, - } + }, } fn main() { diff --git a/docs/_includes/examples/main.rs b/docs/_includes/examples/main.rs index 8bcc7ed..58db8b9 100644 --- a/docs/_includes/examples/main.rs +++ b/docs/_includes/examples/main.rs @@ -8,11 +8,9 @@ pub struct MyStruct { } #[derive(JsonSchema)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { diff --git a/docs/_includes/examples/remote_derive.rs b/docs/_includes/examples/remote_derive.rs index d67a433..db01d8d 100644 --- a/docs/_includes/examples/remote_derive.rs +++ b/docs/_includes/examples/remote_derive.rs @@ -1,6 +1,6 @@ // Pretend that this is somebody else's crate, not a module. mod other_crate { - // Neither Schemars nor the other crate provides a JsonSchema impl + // Neither Schemars nor the other crate provides a JsonSchema impl // for this struct. pub struct Duration { pub secs: i64, diff --git a/docs/_includes/examples/schemars_attrs.rs b/docs/_includes/examples/schemars_attrs.rs index 2d8201a..506beaf 100644 --- a/docs/_includes/examples/schemars_attrs.rs +++ b/docs/_includes/examples/schemars_attrs.rs @@ -14,11 +14,9 @@ pub struct MyStruct { #[derive(Deserialize, Serialize, JsonSchema)] #[schemars(untagged)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { diff --git a/docs/_includes/examples/serde_attrs.rs b/docs/_includes/examples/serde_attrs.rs index cc612e9..249497f 100644 --- a/docs/_includes/examples/serde_attrs.rs +++ b/docs/_includes/examples/serde_attrs.rs @@ -13,11 +13,9 @@ pub struct MyStruct { #[derive(Deserialize, Serialize, JsonSchema)] #[serde(untagged)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { diff --git a/schemars/examples/custom_serialization.rs b/schemars/examples/custom_serialization.rs index 2fc8fa9..9429bc3 100644 --- a/schemars/examples/custom_serialization.rs +++ b/schemars/examples/custom_serialization.rs @@ -38,7 +38,9 @@ mod as_string { D: Deserializer<'de>, { let string = String::deserialize(deserializer)?; - string.parse().map_err(|_| D::Error::custom("Input was not valid")) + string + .parse() + .map_err(|_| D::Error::custom("Input was not valid")) } } diff --git a/schemars/examples/doc_comments.rs b/schemars/examples/doc_comments.rs index 79ecc88..c3faa4f 100644 --- a/schemars/examples/doc_comments.rs +++ b/schemars/examples/doc_comments.rs @@ -16,7 +16,7 @@ pub struct MyStruct { /// # My Amazing Enum #[derive(JsonSchema)] -pub enum MyEnum { +pub enum MyEnum { /// A wrapper around a `String` StringNewType(String), /// A struct-like enum variant which contains @@ -24,7 +24,7 @@ pub enum MyEnum { StructVariant { /// The floats themselves floats: Vec, - } + }, } fn main() { diff --git a/schemars/examples/main.rs b/schemars/examples/main.rs index 8bcc7ed..58db8b9 100644 --- a/schemars/examples/main.rs +++ b/schemars/examples/main.rs @@ -8,11 +8,9 @@ pub struct MyStruct { } #[derive(JsonSchema)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { diff --git a/schemars/examples/remote_derive.rs b/schemars/examples/remote_derive.rs index d67a433..db01d8d 100644 --- a/schemars/examples/remote_derive.rs +++ b/schemars/examples/remote_derive.rs @@ -1,6 +1,6 @@ // Pretend that this is somebody else's crate, not a module. mod other_crate { - // Neither Schemars nor the other crate provides a JsonSchema impl + // Neither Schemars nor the other crate provides a JsonSchema impl // for this struct. pub struct Duration { pub secs: i64, diff --git a/schemars/examples/schemars_attrs.rs b/schemars/examples/schemars_attrs.rs index 2d8201a..506beaf 100644 --- a/schemars/examples/schemars_attrs.rs +++ b/schemars/examples/schemars_attrs.rs @@ -14,11 +14,9 @@ pub struct MyStruct { #[derive(Deserialize, Serialize, JsonSchema)] #[schemars(untagged)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { diff --git a/schemars/examples/serde_attrs.rs b/schemars/examples/serde_attrs.rs index cc612e9..249497f 100644 --- a/schemars/examples/serde_attrs.rs +++ b/schemars/examples/serde_attrs.rs @@ -13,11 +13,9 @@ pub struct MyStruct { #[derive(Deserialize, Serialize, JsonSchema)] #[serde(untagged)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { diff --git a/schemars/src/gen.rs b/schemars/src/gen.rs index 5212bdb..4f61bbf 100644 --- a/schemars/src/gen.rs +++ b/schemars/src/gen.rs @@ -192,7 +192,7 @@ impl SchemaGenerator { /// assert_eq!(extensible_schema, extensible_schema2); /// ``` pub fn make_extensible(&self, schema: SchemaObject) -> SchemaObject { - if schema.is_ref() && !self.settings().allow_ref_siblings{ + if schema.is_ref() && !self.settings().allow_ref_siblings { SchemaObject { subschemas: Some(Box::new(SubschemaValidation { all_of: Some(vec![schema.into()]), diff --git a/schemars/src/json_schema_impls/arrayvec.rs b/schemars/src/json_schema_impls/arrayvec.rs index 5e420a1..047e3d0 100644 --- a/schemars/src/json_schema_impls/arrayvec.rs +++ b/schemars/src/json_schema_impls/arrayvec.rs @@ -15,7 +15,11 @@ where no_ref_schema!(); fn schema_name() -> String { - format!("Array_up_to_size_{}_of_{}", A::CAPACITY, A::Item::schema_name()) + format!( + "Array_up_to_size_{}_of_{}", + A::CAPACITY, + A::Item::schema_name() + ) } fn json_schema(gen: &mut SchemaGenerator) -> Schema { diff --git a/schemars/src/json_schema_impls/maps.rs b/schemars/src/json_schema_impls/maps.rs index 719cc9e..f3f08fa 100644 --- a/schemars/src/json_schema_impls/maps.rs +++ b/schemars/src/json_schema_impls/maps.rs @@ -69,8 +69,7 @@ mod tests { #[test] fn schema_for_map_any_value_no_bool_schema() { - let settings = - SchemaSettings::default().with(|s| s.bool_schemas = BoolSchemas::Disabled); + let settings = SchemaSettings::default().with(|s| s.bool_schemas = BoolSchemas::Disabled); let schema = custom_schema_object_for::>(settings); assert_eq!( schema.instance_type, diff --git a/schemars/src/json_schema_impls/mod.rs b/schemars/src/json_schema_impls/mod.rs index 65fcecf..4259a53 100644 --- a/schemars/src/json_schema_impls/mod.rs +++ b/schemars/src/json_schema_impls/mod.rs @@ -32,22 +32,18 @@ macro_rules! forward_impl { } mod array; +#[cfg(feature = "arrayvec")] +mod arrayvec; #[cfg(std_atomic)] mod atomic; #[cfg(feature = "chrono")] mod chrono; -#[cfg(feature = "indexmap")] -mod indexmap; +mod core; #[cfg(feature = "either")] mod either; -#[cfg(feature = "uuid")] -mod uuid; -#[cfg(feature = "smallvec")] -mod smallvec; -#[cfg(feature = "arrayvec")] -mod arrayvec; -mod core; mod ffi; +#[cfg(feature = "indexmap")] +mod indexmap; mod maps; #[cfg(num_nonzero_signed)] mod nonzero_signed; @@ -55,6 +51,10 @@ mod nonzero_unsigned; mod primitives; mod sequences; mod serdejson; +#[cfg(feature = "smallvec")] +mod smallvec; mod time; mod tuple; +#[cfg(feature = "uuid")] +mod uuid; mod wrapper; diff --git a/schemars/src/lib.rs b/schemars/src/lib.rs index 21c6b30..1568e0f 100644 --- a/schemars/src/lib.rs +++ b/schemars/src/lib.rs @@ -16,11 +16,9 @@ pub struct MyStruct { } #[derive(JsonSchema)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { @@ -125,11 +123,9 @@ pub struct MyStruct { #[derive(Deserialize, Serialize, JsonSchema)] #[serde(untagged)] -pub enum MyEnum { +pub enum MyEnum { StringNewType(String), - StructVariant { - floats: Vec, - } + StructVariant { floats: Vec }, } fn main() { diff --git a/schemars/tests/arrayvec.rs b/schemars/tests/arrayvec.rs index c9903a9..62a2676 100644 --- a/schemars/tests/arrayvec.rs +++ b/schemars/tests/arrayvec.rs @@ -4,10 +4,10 @@ use util::*; #[test] fn arrayvec() -> TestResult { - test_default_generated_schema::>("arrayvec") + test_default_generated_schema::>("arrayvec") } #[test] fn arrayvec_string() -> TestResult { - test_default_generated_schema::>("arrayvec_string") + test_default_generated_schema::>("arrayvec_string") } diff --git a/schemars/tests/remote_derive_generic.rs b/schemars/tests/remote_derive_generic.rs index f38d162..e0164c3 100644 --- a/schemars/tests/remote_derive_generic.rs +++ b/schemars/tests/remote_derive_generic.rs @@ -1,9 +1,9 @@ mod util; use schemars::JsonSchema; -use serde::{Serialize}; -use util::*; +use serde::Serialize; use std::collections::{HashMap, HashSet}; +use util::*; enum Or { #[allow(dead_code)] diff --git a/schemars/tests/uuid.rs b/schemars/tests/uuid.rs index df4d15e..250e2a3 100644 --- a/schemars/tests/uuid.rs +++ b/schemars/tests/uuid.rs @@ -1,6 +1,6 @@ mod util; -use uuid::Uuid; use util::*; +use uuid::Uuid; #[test] fn uuid() -> TestResult { diff --git a/schemars_derive/src/lib.rs b/schemars_derive/src/lib.rs index 2e9c199..042ac49 100644 --- a/schemars_derive/src/lib.rs +++ b/schemars_derive/src/lib.rs @@ -53,7 +53,7 @@ pub fn derive_json_schema(input: proc_macro::TokenStream) -> proc_macro::TokenSt } } } - + let schema_name = if type_params.is_empty() { quote! { #schema_base_name.to_owned() @@ -135,7 +135,7 @@ fn schema_for_enum(variants: &[Variant], cattrs: &serde_attr::Container) -> Toke } fn schema_for_external_tagged_enum<'a>( - variants: impl Iterator> + variants: impl Iterator>, ) -> TokenStream { let (unit_variants, complex_variants): (Vec<_>, Vec<_>) = variants.partition(|v| is_unit_variant(v)); @@ -241,9 +241,7 @@ fn schema_for_internal_tagged_enum<'a>( }) } -fn schema_for_untagged_enum<'a>( - variants: impl Iterator> -) -> TokenStream { +fn schema_for_untagged_enum<'a>(variants: impl Iterator>) -> TokenStream { let schemas = variants.map(|variant| { let schema_expr = schema_for_untagged_enum_variant(variant); set_metadata_on_schema_from_docs(schema_expr, &variant.original.attrs) @@ -257,9 +255,7 @@ fn schema_for_untagged_enum<'a>( }) } -fn schema_for_untagged_enum_variant( - variant: &Variant -) -> TokenStream { +fn schema_for_untagged_enum_variant(variant: &Variant) -> TokenStream { match variant.style { Style::Unit => schema_for_unit_struct(), Style::Newtype => schema_for_newtype_struct(&variant.fields[0]),