From 6868eddcb6cd28ffbdb4743b05f87b1d0348bd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 7 Apr 2018 13:37:44 +0300 Subject: [PATCH] Change Structure/StructureRef to_string() to the minimal required fix And add a comment to why we need it. No other struct with a to_string() function is affected. https://github.com/sdroege/gstreamer-rs/issues/101 --- gstreamer/src/structure.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 86f88ec92..554b8ae96 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -116,15 +116,15 @@ impl Drop for Structure { impl fmt::Debug for Structure { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_tuple("Structure") - .field(&self.as_ref().to_string()) - .finish() + f.debug_tuple("Structure").field(&self.to_string()).finish() } } impl fmt::Display for Structure { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&self.as_ref().to_string()) + // Need to make sure to not call ToString::to_string() here, which + // we have because of the Display impl. We need StructureRef::to_string() + f.write_str(&StructureRef::to_string(self.as_ref())) } } @@ -487,13 +487,13 @@ impl StructureRef { impl fmt::Display for StructureRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&StructureRef::to_string(self)) + f.write_str(&self.to_string()) } } impl fmt::Debug for StructureRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&StructureRef::to_string(self)) + f.write_str(&self.to_string()) } }