jid: impl &{Bare,Full}Jid for String

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2020-05-01 02:25:30 +02:00
parent 36aaa3e681
commit 91c8045329
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -190,6 +190,12 @@ pub struct BareJid {
impl From<FullJid> for String {
fn from(jid: FullJid) -> String {
String::from(&jid)
}
}
impl From<&FullJid> for String {
fn from(jid: &FullJid) -> String {
let mut string = String::new();
if let Some(ref node) = jid.node {
string.push_str(node);
@ -204,6 +210,12 @@ impl From<FullJid> for String {
impl From<BareJid> for String {
fn from(jid: BareJid) -> String {
String::from(&jid)
}
}
impl From<&BareJid> for String {
fn from(jid: &BareJid) -> String {
let mut string = String::new();
if let Some(ref node) = jid.node {
string.push_str(node);