Run cargo fmt
This commit is contained in:
parent
587176fe9f
commit
39bae201eb
4 changed files with 29 additions and 27 deletions
|
@ -25,7 +25,7 @@ macro_rules! decimal_impl {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature="rust_decimal")]
|
#[cfg(feature = "rust_decimal")]
|
||||||
decimal_impl!(rust_decimal::Decimal);
|
decimal_impl!(rust_decimal::Decimal);
|
||||||
#[cfg(feature="bigdecimal")]
|
#[cfg(feature = "bigdecimal")]
|
||||||
decimal_impl!(bigdecimal::BigDecimal);
|
decimal_impl!(bigdecimal::BigDecimal);
|
||||||
|
|
|
@ -18,7 +18,10 @@ impl Iterator for MyIterator {
|
||||||
// which MyIterator does not.
|
// which MyIterator does not.
|
||||||
#[derive(JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
#[schemars(bound = "T::Item: JsonSchema", rename = "MyContainer")]
|
#[schemars(bound = "T::Item: JsonSchema", rename = "MyContainer")]
|
||||||
pub struct MyContainer<T> where T: Iterator {
|
pub struct MyContainer<T>
|
||||||
|
where
|
||||||
|
T: Iterator,
|
||||||
|
{
|
||||||
pub associated: T::Item,
|
pub associated: T::Item,
|
||||||
pub generic: PhantomData<T>,
|
pub generic: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub struct Attrs {
|
||||||
pub examples: Vec<syn::Path>,
|
pub examples: Vec<syn::Path>,
|
||||||
pub repr: Option<syn::Type>,
|
pub repr: Option<syn::Type>,
|
||||||
pub crate_name: Option<syn::Path>,
|
pub crate_name: Option<syn::Path>,
|
||||||
pub is_renamed: bool
|
pub is_renamed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -153,9 +153,7 @@ impl Attrs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Meta(NameValue(m)) if m.path.is_ident("rename") => {
|
Meta(NameValue(m)) if m.path.is_ident("rename") => self.is_renamed = true,
|
||||||
self.is_renamed = true
|
|
||||||
}
|
|
||||||
|
|
||||||
Meta(NameValue(m)) if m.path.is_ident("crate") && attr_type == "schemars" => {
|
Meta(NameValue(m)) if m.path.is_ident("crate") && attr_type == "schemars" => {
|
||||||
if let Ok(p) = parse_lit_into_path(errors, attr_type, "crate", &m.lit) {
|
if let Ok(p) = parse_lit_into_path(errors, attr_type, "crate", &m.lit) {
|
||||||
|
|
|
@ -95,26 +95,27 @@ fn derive_json_schema(
|
||||||
|
|
||||||
// FIXME improve handling of generic type params which may not implement JsonSchema
|
// FIXME improve handling of generic type params which may not implement JsonSchema
|
||||||
let type_params: Vec<_> = cont.generics.type_params().map(|ty| &ty.ident).collect();
|
let type_params: Vec<_> = cont.generics.type_params().map(|ty| &ty.ident).collect();
|
||||||
let schema_name = if type_params.is_empty() || (cont.attrs.is_renamed && !schema_base_name.contains('{')) {
|
let schema_name =
|
||||||
quote! {
|
if type_params.is_empty() || (cont.attrs.is_renamed && !schema_base_name.contains('{')) {
|
||||||
#schema_base_name.to_owned()
|
quote! {
|
||||||
}
|
#schema_base_name.to_owned()
|
||||||
} else if cont.attrs.is_renamed {
|
}
|
||||||
let mut schema_name_fmt = schema_base_name;
|
} else if cont.attrs.is_renamed {
|
||||||
for tp in &type_params {
|
let mut schema_name_fmt = schema_base_name;
|
||||||
schema_name_fmt.push_str(&format!("{{{}:.0}}", tp));
|
for tp in &type_params {
|
||||||
}
|
schema_name_fmt.push_str(&format!("{{{}:.0}}", tp));
|
||||||
quote! {
|
}
|
||||||
format!(#schema_name_fmt #(,#type_params=#type_params::schema_name())*)
|
quote! {
|
||||||
}
|
format!(#schema_name_fmt #(,#type_params=#type_params::schema_name())*)
|
||||||
} else {
|
}
|
||||||
let mut schema_name_fmt = schema_base_name;
|
} else {
|
||||||
schema_name_fmt.push_str("_for_{}");
|
let mut schema_name_fmt = schema_base_name;
|
||||||
schema_name_fmt.push_str(&"_and_{}".repeat(type_params.len() - 1));
|
schema_name_fmt.push_str("_for_{}");
|
||||||
quote! {
|
schema_name_fmt.push_str(&"_and_{}".repeat(type_params.len() - 1));
|
||||||
format!(#schema_name_fmt #(,#type_params::schema_name())*)
|
quote! {
|
||||||
}
|
format!(#schema_name_fmt #(,#type_params::schema_name())*)
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let schema_expr = if repr {
|
let schema_expr = if repr {
|
||||||
schema_exprs::expr_for_repr(&cont).map_err(|e| vec![e])?
|
schema_exprs::expr_for_repr(&cont).map_err(|e| vec![e])?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue