Revert "core/formats: implement ToString instead of Display for NAChannelType"
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 8 Jul 2020 16:51:29 +0000 (18:51 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 8 Jul 2020 16:51:29 +0000 (18:51 +0200)
This reverts commit 81b94329a275bb92066404bd3bb2822c5bb3f424.

I forgot that implemented Display means automatic ToString() and not vice versa.

nihav-core/src/formats.rs

index 6d7f1a152caba62dfa1c78c402c963c933109483..f96eb53028ba4283c35015241a6ed90f69cf0a4c 100644 (file)
@@ -216,9 +216,9 @@ impl FromStr for NAChannelType {
     }
 }
 
-impl ToString for NAChannelType {
-    fn to_string(&self) -> String {
-        match *self {
+impl fmt::Display for NAChannelType {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        let name = match *self {
             NAChannelType::C    => "C".to_string(),
             NAChannelType::L    => "L".to_string(),
             NAChannelType::R    => "R".to_string(),
@@ -247,7 +247,8 @@ impl ToString for NAChannelType {
             NAChannelType::Rt   => "Rt".to_string(),
             NAChannelType::Lo   => "Lo".to_string(),
             NAChannelType::Ro   => "Ro".to_string(),
-        }
+        };
+        write!(f, "{}", name)
     }
 }