From 22f9b6f0bdc473c965affd224650b2bd9c2d9205 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Thu, 17 Nov 2022 10:42:59 +0000 Subject: [PATCH] Implement Display for SimplePath --- lib/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/src/lib.rs b/lib/src/lib.rs index b506f71..db05a23 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -31,6 +31,19 @@ pub use singleton::{Singleton, SingletonField, SingletonScope}; #[derive(PartialEq, Eq)] pub struct SimplePath(&'static [&'static str]); +impl std::fmt::Display for SimplePath { + fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + if !self.0.is_empty() { + write!(f, "{}", self.0[0])?; + for component in &self.0[1..] { + write!(f, "::{}", component)?; + } + } + + Ok(()) + } +} + impl SimplePath { /// Construct, verifying validity ///