Skip to content

Commit

Permalink
Fix clippy error: direct implementation of ToString
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka committed Dec 5, 2024
1 parent 4592113 commit c9e02b0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions argp_derive/src/parse_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// SPDX-FileCopyrightText: 2023 Jakub Jirutka <[email protected]>
// SPDX-FileCopyrightText: 2020 Google LLC

use std::fmt;

use proc_macro2::Span;

use crate::errors::Errors;
Expand Down Expand Up @@ -204,17 +206,17 @@ impl FieldAttrs {
}
}

impl ToString for Description {
fn to_string(&self) -> String {
impl fmt::Display for Description {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.explicit {
self.lines.join("\n")
f.write_str(&self.lines.join("\n"))
} else {
let mut buf = String::new();
for line in &self.lines {
buf.push_str(&line.replace('\n', "\\n"));
buf.push('\n');
}
markdown::to_plain_text(&buf)
f.write_str(&markdown::to_plain_text(&buf))
}
}
}
Expand Down

0 comments on commit c9e02b0

Please sign in to comment.