Skip to content

Commit

Permalink
implement Display for string conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Aug 5, 2024
1 parent 79d563b commit f295a17
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/identifier.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::Display;
use std::str::FromStr;

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f295a17

Please sign in to comment.