From 885aae39c5a29356f7930b0eb04b692d0f2a578d Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 22 Jul 2020 20:22:17 +0200 Subject: [PATCH] Add From<&T> for Box implementations for ServerName, DeviceId --- ruma-identifiers/src/device_id.rs | 6 ++++++ ruma-identifiers/src/server_name.rs | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ruma-identifiers/src/device_id.rs b/ruma-identifiers/src/device_id.rs index 217c4311..86d3d8bf 100644 --- a/ruma-identifiers/src/device_id.rs +++ b/ruma-identifiers/src/device_id.rs @@ -58,6 +58,12 @@ impl ToOwned for DeviceId { } } +impl From<&DeviceId> for Box { + fn from(id: &DeviceId) -> Self { + id.to_owned() + } +} + impl AsRef for DeviceId { fn as_ref(&self) -> &str { self.as_str() diff --git a/ruma-identifiers/src/server_name.rs b/ruma-identifiers/src/server_name.rs index a3783ae5..947bd4fa 100644 --- a/ruma-identifiers/src/server_name.rs +++ b/ruma-identifiers/src/server_name.rs @@ -48,6 +48,12 @@ impl ToOwned for ServerName { } } +impl From<&ServerName> for Box { + fn from(s: &ServerName) -> Self { + s.to_owned() + } +} + pub(crate) fn validate(server_name: &str) -> Result<(), Error> { use std::net::Ipv6Addr; @@ -114,8 +120,8 @@ impl AsRef for Box { } impl From> for String { - fn from(id: Box) -> Self { - id.into_owned().into() + fn from(s: Box) -> Self { + s.into_owned().into() } }