From c1236e68f32511332c79d2195876eb51aaaa7c5e Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 7 Jul 2018 03:41:40 +0200 Subject: more readability --- src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 98f47ae..010944f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,6 +37,8 @@ pub mod statistics; use statistics::gamedata::{self, Boss}; +use std::fmt; + /// A macro that returns `true` when the given expression matches the pattern. /// /// ```rust @@ -92,6 +94,18 @@ pub enum AgentName { }, } +impl fmt::Display for AgentName { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let name = match *self { + AgentName::Single(ref name) => name, + AgentName::Player { + ref character_name, .. + } => character_name, + }; + f.write_str(name) + } +} + /// An agent. #[derive(Debug, Clone, Getters)] pub struct Agent { -- cgit v1.2.3