Skip to content

Commit

Permalink
Implement Display instead of ToString for Chart
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaOber committed Oct 6, 2024
1 parent dd62e84 commit 772395d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions charming/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(clippy::to_string_trait_impl)]
#![cfg_attr(docsrs, feature(doc_cfg))]
/*!
Charming is a powerful and versatile chart rendering library for Rust that
Expand Down Expand Up @@ -516,9 +515,13 @@ impl Chart {
}
}

impl ToString for Chart {
fn to_string(&self) -> String {
process_raw_strings(serde_json::to_string_pretty(self).unwrap().as_str())
impl std::fmt::Display for Chart {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
process_raw_strings(&serde_json::to_string_pretty(self).unwrap())
)
}
}

Expand Down

0 comments on commit 772395d

Please sign in to comment.