From e81b5717e96210f5a66e5c9a1d49b098aea12d74 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 18 Jun 2019 15:45:33 +0530 Subject: [PATCH] audio: fix AudioFormat Display implementation We were calling the blanket implementation of ToString, which is using Display, rather than our own, resulting in an infinite recursion. --- gstreamer-audio/src/audio_format.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gstreamer-audio/src/audio_format.rs b/gstreamer-audio/src/audio_format.rs index 90c62dc13..ce5fe4809 100644 --- a/gstreamer-audio/src/audio_format.rs +++ b/gstreamer-audio/src/audio_format.rs @@ -73,7 +73,7 @@ impl str::FromStr for ::AudioFormat { impl fmt::Display for ::AudioFormat { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - f.write_str(self.to_string().as_str()) + f.write_str(::AudioFormat::to_string(*self)) } } @@ -134,3 +134,15 @@ pub const AUDIO_FORMAT_U18: ::AudioFormat = ::AudioFormat::U18le; pub const AUDIO_FORMAT_F32: ::AudioFormat = ::AudioFormat::F32le; #[cfg(target_endian = "little")] pub const AUDIO_FORMAT_F64: ::AudioFormat = ::AudioFormat::F64le; + +#[cfg(test)] +mod tests { + use gst; + + #[test] + fn test_display() { + gst::init().unwrap(); + + format!("{}", ::AudioFormat::S16be); + } +}