1
0
mirror of https://gitlab.com/xmpp-rs/xmpp-rs.git synced 2024-06-26 17:08:26 +02:00

Implement the Debug trait in a more user-friendly way.

This commit is contained in:
Emmanuel Gil Peyrot 2017-04-30 21:44:17 +01:00
parent 0288b937df
commit c13cebf025

View File

@ -24,7 +24,7 @@ pub enum JidParseError {
/// - A node/name, `node`, which is the optional part before the @.
/// - A domain, `domain`, which is the mandatory part after the @ but before the /.
/// - A resource, `resource`, which is the optional part after the /.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq)]
pub struct Jid {
/// The node part of the Jabber ID, if it exists, else None.
pub node: Option<String>,
@ -50,6 +50,13 @@ impl From<Jid> for String {
}
}
impl fmt::Debug for Jid {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "JID({})", self)?;
Ok(())
}
}
impl fmt::Display for Jid {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fmt.write_str(String::from(self.clone()).as_ref())?;