From f295a1750781afaa45e099e34db801411d134855 Mon Sep 17 00:00:00 2001 From: Jan Range Date: Mon, 5 Aug 2024 22:57:54 +0200 Subject: [PATCH] implement `Display` for string conversion --- src/identifier.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/identifier.rs b/src/identifier.rs index 9064beb..d21a414 100644 --- a/src/identifier.rs +++ b/src/identifier.rs @@ -1,3 +1,4 @@ +use std::fmt::Display; use std::str::FromStr; use serde::{Deserialize, Serialize}; @@ -30,6 +31,16 @@ impl FromStr for Identifier { } } +impl Display for Identifier { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let str = match self { + Identifier::Id(id) => id.to_string(), + Identifier::PersistentId(pid) => pid.to_owned(), + }; + write!(f, "{}", str) + } +} + #[cfg(test)] mod tests {