Resolve clippy warnings
This commit is contained in:
parent
e0495c0c87
commit
072730f6f6
6 changed files with 15 additions and 18 deletions
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rust-analyzer.check.command": "clippy"
|
||||||
|
}
|
|
@ -171,8 +171,10 @@ fn is_null_type(schema: &Schema) -> bool {
|
||||||
Schema::Object(s) => s,
|
Schema::Object(s) => s,
|
||||||
_ => return false,
|
_ => return false,
|
||||||
};
|
};
|
||||||
match &s.instance_type {
|
let instance_type = match &s.instance_type {
|
||||||
Some(SingleOrVec::Single(t)) if **t == InstanceType::Null => true,
|
Some(SingleOrVec::Single(t)) => t,
|
||||||
_ => false,
|
_ => return false,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
**instance_type == InstanceType::Null
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ use std::{any::Any, collections::HashSet, fmt::Debug};
|
||||||
/// The default settings currently conform to [JSON Schema Draft 7](https://json-schema.org/specification-links.html#draft-7), but this is liable to change in a future version of Schemars if support for other JSON Schema versions is added.
|
/// The default settings currently conform to [JSON Schema Draft 7](https://json-schema.org/specification-links.html#draft-7), but this is liable to change in a future version of Schemars if support for other JSON Schema versions is added.
|
||||||
/// If you require your generated schemas to conform to draft 7, consider using the [`draft07`](#method.draft07) method.
|
/// If you require your generated schemas to conform to draft 7, consider using the [`draft07`](#method.draft07) method.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct SchemaSettings {
|
pub struct SchemaSettings {
|
||||||
/// If `true`, schemas for [`Option<T>`](Option) will include a `nullable` property.
|
/// If `true`, schemas for [`Option<T>`](Option) will include a `nullable` property.
|
||||||
///
|
///
|
||||||
|
@ -45,7 +46,6 @@ pub struct SchemaSettings {
|
||||||
///
|
///
|
||||||
/// Defaults to `false`.
|
/// Defaults to `false`.
|
||||||
pub inline_subschemas: bool,
|
pub inline_subschemas: bool,
|
||||||
_hidden: (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SchemaSettings {
|
impl Default for SchemaSettings {
|
||||||
|
@ -64,7 +64,6 @@ impl SchemaSettings {
|
||||||
meta_schema: Some("http://json-schema.org/draft-07/schema#".to_owned()),
|
meta_schema: Some("http://json-schema.org/draft-07/schema#".to_owned()),
|
||||||
visitors: vec![Box::new(RemoveRefSiblings)],
|
visitors: vec![Box::new(RemoveRefSiblings)],
|
||||||
inline_subschemas: false,
|
inline_subschemas: false,
|
||||||
_hidden: (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +76,6 @@ impl SchemaSettings {
|
||||||
meta_schema: Some("https://json-schema.org/draft/2019-09/schema".to_owned()),
|
meta_schema: Some("https://json-schema.org/draft/2019-09/schema".to_owned()),
|
||||||
visitors: Vec::default(),
|
visitors: Vec::default(),
|
||||||
inline_subschemas: false,
|
inline_subschemas: false,
|
||||||
_hidden: (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +99,6 @@ impl SchemaSettings {
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
inline_subschemas: false,
|
inline_subschemas: false,
|
||||||
_hidden: (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,7 @@ impl<'a> Variant<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_unit(&self) -> bool {
|
pub fn is_unit(&self) -> bool {
|
||||||
match self.style {
|
matches!(self.style, serde_ast::Style::Unit)
|
||||||
serde_ast::Style::Unit => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,8 +190,7 @@ impl Attrs {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_default(&self) -> bool {
|
pub fn is_default(&self) -> bool {
|
||||||
match self {
|
matches!(self, Self {
|
||||||
Self {
|
|
||||||
with: None,
|
with: None,
|
||||||
title: None,
|
title: None,
|
||||||
description: None,
|
description: None,
|
||||||
|
@ -200,9 +199,7 @@ impl Attrs {
|
||||||
repr: None,
|
repr: None,
|
||||||
crate_name: None,
|
crate_name: None,
|
||||||
is_renamed: _,
|
is_renamed: _,
|
||||||
} if examples.is_empty() => true,
|
} if examples.is_empty())
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
#![allow(clippy::all)]
|
||||||
// Copied from regex_syntax crate to avoid pulling in the whole crate just for a utility function
|
// Copied from regex_syntax crate to avoid pulling in the whole crate just for a utility function
|
||||||
// https://github.com/rust-lang/regex/blob/ff283badce21dcebd581909d38b81f2c8c9bfb54/regex-syntax/src/lib.rs
|
// https://github.com/rust-lang/regex/blob/431c4e4867e1eb33eb39b23ed47c9934b2672f8f/regex-syntax/src/lib.rs
|
||||||
//
|
//
|
||||||
// Copyright (c) 2014 The Rust Project Developers
|
// Copyright (c) 2014 The Rust Project Developers
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue