]> git.proxmox.com Git - proxmox.git/commitdiff
schema: clippy fixups
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 31 May 2022 07:42:25 +0000 (09:42 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 31 May 2022 07:42:25 +0000 (09:42 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
proxmox-schema/src/format.rs
proxmox-schema/src/schema.rs

index 65ae6dac5d7f0e4842ffa58934d957d6634d2ead..0246b728ba61d3da6ced539db707997aa7263617 100644 (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 => {
index 10d02b17bd47eedbb46de9abb34458769d424dfe..a2b165c810db4a91582de54eb693cd6d110ac847 100644 (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)