Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» zn: Improve BusName Debug impl
Browse files Browse the repository at this point in the history
This makes Debug impl of BusName transparent

Before:

Unique(UniqueName("foo"))

After:

UniqueName("foo")
  • Loading branch information
SeaDve committed Aug 19, 2023
1 parent 9f78e4b commit aa01d00
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion zbus_names/src/bus_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use zvariant::{NoneValue, OwnedValue, Str, Type, Value};
/// ```
///
/// [bus name]: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize)]
#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize)]
#[serde(untagged)]
pub enum BusName<'name> {
#[serde(borrow)]
Expand Down Expand Up @@ -112,6 +112,15 @@ impl Borrow<str> for BusName<'_> {
}
}

impl Debug for BusName<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
BusName::Unique(n) => Debug::fmt(&n, f),
BusName::WellKnown(n) => Debug::fmt(&n, f),
}
}
}

impl Display for BusName<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
Display::fmt(&self.as_str(), f)
Expand Down

0 comments on commit aa01d00

Please sign in to comment.