From 8d9288ffd7aefaa015580f9cafe63c7af38b894e Mon Sep 17 00:00:00 2001 From: xmppftw Date: Sun, 28 May 2023 20:02:09 +0200 Subject: [PATCH] Implement From<&Jid> for String (close #69) --- jid/CHANGELOG.md | 2 ++ jid/src/lib.rs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/jid/CHANGELOG.md b/jid/CHANGELOG.md index 0084f65..a252435 100644 --- a/jid/CHANGELOG.md +++ b/jid/CHANGELOG.md @@ -2,6 +2,8 @@ Unreleased * Breaking - serde: Jid is now using untagged enum representation (#66) + * Additions + - From<&Jid> is now implemented for String (#69) Version 0.9.3, release 2022-03-07: * Updates diff --git a/jid/src/lib.rs b/jid/src/lib.rs index ebed432..fa89863 100644 --- a/jid/src/lib.rs +++ b/jid/src/lib.rs @@ -105,6 +105,15 @@ impl From for String { } } +impl From<&Jid> for String { + fn from(jid: &Jid) -> String { + match jid { + Jid::Bare(bare) => String::from(bare), + Jid::Full(full) => String::from(full), + } + } +} + impl From for Jid { fn from(bare_jid: BareJid) -> Jid { Jid::Bare(bare_jid)