From 59fc76a2d462746e9f79a7694dbb6737cfe9968c Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sat, 17 Oct 2020 11:42:37 +0100 Subject: [PATCH] implement Format instead of just ToString --- src/exit.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/exit.rs b/src/exit.rs index 9d37cee..b53968d 100644 --- a/src/exit.rs +++ b/src/exit.rs @@ -2,6 +2,7 @@ use crate::Position; use std::str::FromStr; use std::error::Error; use std::fmt; +use std::fmt::{Display, Formatter}; #[derive(Clone, Debug, Eq, PartialEq)] pub enum Transition { @@ -32,9 +33,9 @@ impl From<&str> for Transition { } } -impl ToString for Transition { - fn to_string(&self) -> String { - match &self { +impl Display for Transition { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{}", match &self { Transition::FadeToWhite => " FX fade_w", Transition::FadeToBlack => " FX fade_b", Transition::Wave => " FX wave", @@ -44,8 +45,7 @@ impl ToString for Transition { Transition::SlideLeft => " FX slide_l", Transition::SlideRight => " FX slide_r", Transition::None => "", - } - .to_string() + }) } }