-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix clippy error: direct implementation of ToString
- Loading branch information
Showing
1 changed file
with
6 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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)) | ||
} | ||
} | ||
} | ||
|