From b88c621214bc03c3e70793c94ac659dae6211cbc Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Tue, 23 Jul 2019 00:26:46 -0700 Subject: [PATCH] impl Display for Action --- src/push_rules.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/push_rules.rs b/src/push_rules.rs index d965712e..27cc3ca5 100644 --- a/src/push_rules.rs +++ b/src/push_rules.rs @@ -1,7 +1,7 @@ //! Types for the the *m.push_rules* event. use std::{ - fmt::{Formatter, Result as FmtResult}, + fmt::{Display, Formatter, Result as FmtResult}, str::FromStr, }; @@ -142,6 +142,22 @@ pub enum Action { __Nonexhaustive, } +impl Display for Action { + fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { + let variant = match *self { + Action::Notify => "notify", + Action::DontNotify => "dont_notify", + Action::Coalesce => "coalesce", + Action::SetTweak(_) => "set_tweak", + Action::__Nonexhaustive => { + panic!("__Nonexhaustive enum variant is not intended for use.") + } + }; + + write!(f, "{}", variant) + } +} + impl FromStr for Action { type Err = FromStrError;