diff options
Diffstat (limited to 'common/object')
| -rw-r--r-- | common/object/src/path.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/common/object/src/path.rs b/common/object/src/path.rs index fc14e6d..0751ff0 100644 --- a/common/object/src/path.rs +++ b/common/object/src/path.rs @@ -5,7 +5,7 @@ */ use crate::{Object, Tag, TypedTag}; -use std::marker::PhantomData; +use std::{fmt::Display, marker::PhantomData}; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Path(pub Vec<Tag>); @@ -36,3 +36,15 @@ impl Path { out } } + +impl Display for Path { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + for (i, c) in self.0.iter().enumerate() { + if i > 0 { + write!(f, ".")?; + } + write!(f, "{c}")?; + } + Ok(()) + } +} |