implement Format instead of just ToString

This commit is contained in:
Max Bradbury 2020-10-17 11:42:37 +01:00
parent 676c71cd45
commit 59fc76a2d4
1 changed files with 5 additions and 5 deletions

View File

@ -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()
})
}
}