mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
Merge branch 'master' into 'master'
Impl Display for Jid See merge request xmpp-rs/jid-rs!18
This commit is contained in:
commit
d5789ea1d1
1 changed files with 14 additions and 0 deletions
14
src/lib.rs
14
src/lib.rs
|
@ -92,6 +92,12 @@ impl From<FullJid> for Jid {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Jid {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
fmt.write_str(String::from(self.clone()).as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl Jid {
|
||||
/// The node part of the Jabber ID, if it exists, else None.
|
||||
pub fn node(self) -> Option<String> {
|
||||
|
@ -696,6 +702,14 @@ mod tests {
|
|||
assert_eq!(FullJid::from_str("a@b"), Err(JidParseError::NoResource));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_jids() {
|
||||
assert_eq!(format!("{}", FullJid::new("a", "b", "c")), String::from("a@b/c"));
|
||||
assert_eq!(format!("{}", BareJid::new("a", "b")), String::from("a@b"));
|
||||
assert_eq!(format!("{}", Jid::Full(FullJid::new("a", "b", "c"))), String::from("a@b/c"));
|
||||
assert_eq!(format!("{}", Jid::Bare(BareJid::new("a", "b"))), String::from("a@b"));
|
||||
}
|
||||
|
||||
#[cfg(feature = "minidom")]
|
||||
#[test]
|
||||
fn minidom() {
|
||||
|
|
Loading…
Reference in a new issue