schema: clippy fixups

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2022-05-31 09:42:25 +02:00
parent 17805f9791
commit 9079afc831
2 changed files with 14 additions and 6 deletions

View File

@ -5,7 +5,7 @@ use anyhow::{bail, Error};
use crate::*;
/// Enumerate different styles to display parameters/properties.
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum ParameterDisplayStyle {
/// Used for properties in configuration files: ``key:``
Config,
@ -18,7 +18,7 @@ pub enum ParameterDisplayStyle {
}
/// CLI usage information format.
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum DocumentationFormat {
/// Text, command line only (one line).
Short,
@ -122,7 +122,7 @@ pub fn dump_properties(
if !indent.is_empty() {
param_descr = format!("{}{}", indent, param_descr); // indent first line
param_descr = param_descr.replace("\n", &format!("\n{}", indent)); // indent rest
param_descr = param_descr.replace('\n', &format!("\n{}", indent)); // indent rest
}
if style == ParameterDisplayStyle::Config {
@ -398,7 +398,10 @@ pub fn dump_enum_properties(schema: &Schema) -> Result<String, Error> {
}) = schema
{
for item in variants.iter() {
res.push_str(&format!(":``{}``: ", item.value));
use std::fmt::Write;
let _ = write!(res, ":``{}``: ", item.value);
//res.push_str(&format!(":``{}``: ", item.value));
let descr = wrap_text("", " ", item.description, 80);
res.push_str(&descr);
res.push('\n');
@ -410,6 +413,8 @@ pub fn dump_enum_properties(schema: &Schema) -> Result<String, Error> {
}
pub fn dump_api_return_schema(returns: &ReturnType, style: ParameterDisplayStyle) -> String {
use std::fmt::Write;
let schema = &returns.schema;
let mut res = if returns.optional {
@ -419,7 +424,8 @@ pub fn dump_api_return_schema(returns: &ReturnType, style: ParameterDisplayStyle
};
let type_text = get_schema_type_text(schema, style);
res.push_str(&format!("**{}**\n\n", type_text));
//res.push_str(&format!("**{}**\n\n", type_text));
let _ = write!(res, "**{}**\n\n", type_text);
match schema {
Schema::Null => {

View File

@ -92,6 +92,8 @@ impl ParameterError {
impl fmt::Display for ParameterError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use std::fmt::Write;
let mut msg = String::new();
if !self.is_empty() {
@ -99,7 +101,7 @@ impl fmt::Display for ParameterError {
}
for (name, err) in self.error_list.iter() {
msg.push_str(&format!("parameter '{}': {}\n", name, err));
let _ = writeln!(msg, "parameter '{}': {}", name, err);
}
write!(f, "{}", msg)