Wrap comment lines at 100 chars

This commit is contained in:
Graham Esau 2024-08-30 13:05:33 +01:00
parent 0672c862c8
commit 5d58a4d3f0
9 changed files with 147 additions and 92 deletions

View file

@ -89,8 +89,9 @@ impl CommonAttrs {
"extend" => {
for ex in parse_extensions(meta, cx).into_iter().flatten() {
// This is O(n^2) but should be fine with the typically small number of extensions.
// If this does become a problem, it can be changed to use IndexMap, or a separate Map with cloned keys.
// This is O(n^2) but should be fine with the typically small number of
// extensions. If this does become a problem, it can be changed to use
// IndexMap, or a separate Map with cloned keys.
if self.extensions.iter().any(|e| e.0 == ex.key_str) {
cx.error_spanned_by(
ex.key_lit,

View file

@ -6,7 +6,8 @@ use syn::{Attribute, Data, Field, Meta, Variant};
use super::get_meta_items;
// List of keywords that can appear in #[serde(...)]/#[schemars(...)] attributes which we want serde_derive_internals to parse for us.
// List of keywords that can appear in #[serde(...)]/#[schemars(...)] attributes which we want
// serde_derive_internals to parse for us.
pub(crate) static SERDE_KEYWORDS: &[&str] = &[
"rename",
"rename_all",
@ -23,12 +24,15 @@ pub(crate) static SERDE_KEYWORDS: &[&str] = &[
"flatten",
"remote",
"transparent",
// Special case - `bound` is removed from serde attrs, so is only respected when present in schemars attr.
// Special case - `bound` is removed from serde attrs, so is only respected when present in
// schemars attr.
"bound",
// Special cases - `with`/`serialize_with` are passed to serde but not copied from schemars attrs to serde attrs.
// This is because we want to preserve any serde attribute's `serialize_with` value to determine whether the field's
// default value should be serialized. We also check the `with` value on schemars/serde attrs e.g. to support deriving
// JsonSchema on remote types, but we parse that ourselves rather than using serde_derive_internals.
// Special cases - `with`/`serialize_with` are passed to serde but not copied from schemars
// attrs to serde attrs. This is because we want to preserve any serde attribute's
// `serialize_with` value to determine whether the field's default value should be
// serialized. We also check the `with` value on schemars/serde attrs e.g. to support deriving
// JsonSchema on remote types, but we parse that ourselves rather than using
// serde_derive_internals.
"serialize_with",
"with",
];

View file

@ -201,8 +201,11 @@ fn add_trait_bounds(cont: &mut Container) {
let where_clause = cont.generics.make_where_clause();
where_clause.predicates.extend(bounds.iter().cloned());
} else {
// No explicit trait bounds specified, assume the Rust convention of adding the trait to each type parameter
// TODO consider also adding trait bound to associated types when used as fields - I think Serde does this?
// No explicit trait bounds specified, assume the Rust convention of adding the trait to
// each type parameter
//
// TODO consider also adding trait bound to associated types
// when used as fields - I think Serde does this?
for param in &mut cont.generics.params {
if let syn::GenericParam::Type(ref mut type_param) = *param {
type_param.bounds.push(parse_quote!(schemars::JsonSchema));