Skip to content

Commit

Permalink
Implement Display for SimplePath
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Nov 17, 2022
1 parent 2951dc3 commit 22f9b6f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down

0 comments on commit 22f9b6f

Please sign in to comment.