Apply some clippy suggestions
This commit is contained in:
parent
b8c548136a
commit
3a7d7ad905
7 changed files with 15 additions and 22 deletions
|
@ -27,10 +27,8 @@ pub enum MyEnum {
|
||||||
StructVariant { floats: Vec<f32> },
|
StructVariant { floats: Vec<f32> },
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let schema = schema_for!(MyStruct);
|
let schema = schema_for!(MyStruct);
|
||||||
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
@ -133,10 +131,8 @@ pub enum MyEnum {
|
||||||
StructVariant { floats: Vec<f32> },
|
StructVariant { floats: Vec<f32> },
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let schema = schema_for!(MyStruct);
|
let schema = schema_for!(MyStruct);
|
||||||
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
1
clippy.toml
Normal file
1
clippy.toml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
msrv = "1.36.0"
|
|
@ -335,8 +335,8 @@ impl SchemaGenerator {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn apply_metadata(&self, schema: Schema, metadata: Option<Metadata>) -> Schema {
|
pub fn apply_metadata(&self, schema: Schema, metadata: Option<Metadata>) -> Schema {
|
||||||
match metadata {
|
match metadata {
|
||||||
None => return schema,
|
None => schema,
|
||||||
Some(ref metadata) if *metadata == Metadata::default() => return schema,
|
Some(ref metadata) if *metadata == Metadata::default() => schema,
|
||||||
Some(metadata) => {
|
Some(metadata) => {
|
||||||
let mut schema_obj = schema.into_object();
|
let mut schema_obj = schema.into_object();
|
||||||
schema_obj.metadata = Some(Box::new(metadata)).merge(schema_obj.metadata);
|
schema_obj.metadata = Some(Box::new(metadata)).merge(schema_obj.metadata);
|
||||||
|
|
|
@ -22,10 +22,8 @@ pub enum MyEnum {
|
||||||
StructVariant { floats: Vec<f32> },
|
StructVariant { floats: Vec<f32> },
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let schema = schema_for!(MyStruct);
|
let schema = schema_for!(MyStruct);
|
||||||
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
@ -128,10 +126,8 @@ pub enum MyEnum {
|
||||||
StructVariant { floats: Vec<f32> },
|
StructVariant { floats: Vec<f32> },
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let schema = schema_for!(MyStruct);
|
let schema = schema_for!(MyStruct);
|
||||||
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
|
@ -52,7 +52,7 @@ fn get_doc(attrs: &[Attribute]) -> Option<String> {
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|a| a.split('\n'))
|
.flat_map(|a| a.split('\n'))
|
||||||
.map(str::trim)
|
.map(str::trim)
|
||||||
.skip_while(|s| *s == "")
|
.skip_while(|s| s.is_empty())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if let Some(&"") = lines.last() {
|
if let Some(&"") = lines.last() {
|
||||||
|
@ -61,7 +61,7 @@ fn get_doc(attrs: &[Attribute]) -> Option<String> {
|
||||||
|
|
||||||
// Added for backward-compatibility, but perhaps we shouldn't do this
|
// Added for backward-compatibility, but perhaps we shouldn't do this
|
||||||
// https://github.com/rust-lang/rust/issues/32088
|
// https://github.com/rust-lang/rust/issues/32088
|
||||||
if lines.iter().all(|l| l.starts_with("*")) {
|
if lines.iter().all(|l| l.starts_with('*')) {
|
||||||
for line in lines.iter_mut() {
|
for line in lines.iter_mut() {
|
||||||
*line = line[1..].trim()
|
*line = line[1..].trim()
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl<'a> SchemaMetadata<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn none_if_empty<'a>(s: &'a String) -> Option<&'a str> {
|
fn none_if_empty(s: &String) -> Option<&str> {
|
||||||
if s.is_empty() {
|
if s.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -98,7 +98,7 @@ fn expr_for_external_tagged_enum<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut schemas = Vec::new();
|
let mut schemas = Vec::new();
|
||||||
if unit_variants.len() > 0 {
|
if !unit_variants.is_empty() {
|
||||||
schemas.push(unit_schema);
|
schemas.push(unit_schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue