Add From<&T> for Box<T> implementations for ServerName, DeviceId

This commit is contained in:
Jonas Platte 2020-07-22 20:22:17 +02:00
parent 4cbdc079b0
commit 885aae39c5
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
2 changed files with 14 additions and 2 deletions

View File

@ -58,6 +58,12 @@ impl ToOwned for DeviceId {
} }
} }
impl From<&DeviceId> for Box<DeviceId> {
fn from(id: &DeviceId) -> Self {
id.to_owned()
}
}
impl AsRef<str> for DeviceId { impl AsRef<str> for DeviceId {
fn as_ref(&self) -> &str { fn as_ref(&self) -> &str {
self.as_str() self.as_str()

View File

@ -48,6 +48,12 @@ impl ToOwned for ServerName {
} }
} }
impl From<&ServerName> for Box<ServerName> {
fn from(s: &ServerName) -> Self {
s.to_owned()
}
}
pub(crate) fn validate(server_name: &str) -> Result<(), Error> { pub(crate) fn validate(server_name: &str) -> Result<(), Error> {
use std::net::Ipv6Addr; use std::net::Ipv6Addr;
@ -114,8 +120,8 @@ impl AsRef<str> for Box<ServerName> {
} }
impl From<Box<ServerName>> for String { impl From<Box<ServerName>> for String {
fn from(id: Box<ServerName>) -> Self { fn from(s: Box<ServerName>) -> Self {
id.into_owned().into() s.into_owned().into()
} }
} }