From 6a5bd3840211dc2a8f8c7aa9ad79a839c159f14a Mon Sep 17 00:00:00 2001 From: Chris Wailes Date: Thu, 9 May 2024 15:24:18 -0700 Subject: Replace impl ToString with impl Display If the Display interface is implemented the compiler will automatically derive an implementation of ToString. Test: m rust Bug: 333887339 Change-Id: Ib07011b5004bdc42b60eff7405528b72e77b9496 --- profcollectd/libprofcollectd/config.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/profcollectd/libprofcollectd/config.rs b/profcollectd/libprofcollectd/config.rs index af714242..cdf14879 100644 --- a/profcollectd/libprofcollectd/config.rs +++ b/profcollectd/libprofcollectd/config.rs @@ -82,9 +82,9 @@ impl Config { } } -impl ToString for Config { - fn to_string(&self) -> String { - serde_json::to_string(self).expect("Failed to deserialise configuration.") +impl std::fmt::Display for Config { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", serde_json::to_string(self).expect("Failed to deserialise configuration.")) } } -- cgit v1.2.3