[pbs-devel] [PATCH backup 3/4] report: inline errors in writeln!

Maximiliano Sandoval m.sandoval at proxmox.com
Tue Feb 13 10:53:19 CET 2024


Fixes the clippy lint:

```
warning: `to_string` applied to a type that implements `Display` in `writeln!` args
   --> src/server/report.rs:141:72
    |
141 |                 let _ = writeln!(out, "error during read-dir - {}", err.to_string());
    |                                                                        ^^^^^^^^^^^^ help: remove this
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args
```

Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 src/server/report.rs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/server/report.rs b/src/server/report.rs
index d97efb14..ca5f04fc 100644
--- a/src/server/report.rs
+++ b/src/server/report.rs
@@ -126,9 +126,8 @@ fn get_directory_content(path: impl AsRef<Path>) -> String {
         Ok(iter) => iter,
         Err(err) => {
             return format!(
-                "`$ cat '{}*'`\n```\n# read dir failed - {}\n```",
+                "`$ cat '{}*'`\n```\n# read dir failed - {err}\n```",
                 path.as_ref().display(),
-                err.to_string(),
             );
         }
     };
@@ -138,7 +137,7 @@ fn get_directory_content(path: impl AsRef<Path>) -> String {
         let entry = match entry {
             Ok(entry) => entry,
             Err(err) => {
-                let _ = writeln!(out, "error during read-dir - {}", err.to_string());
+                let _ = writeln!(out, "error during read-dir - {err}");
                 continue;
             }
         };
-- 
2.39.2





More information about the pbs-devel mailing list