identifiers: Add From<OwnedId> impls for String

This commit is contained in:
Kévin Commaille 2022-11-11 18:02:27 +01:00 committed by Kévin Commaille
parent c75d97772c
commit 67abaf4de1

View File

@ -249,6 +249,15 @@ fn expand_owned_id(input: &ItemStruct) -> TokenStream {
} }
} }
impl #impl_generics From<#owned_ty> for String {
fn from(id: #owned_ty) -> String {
#[cfg(not(any(ruma_identifiers_storage = "Arc")))]
{ id.inner.into() }
#[cfg(ruma_identifiers_storage = "Arc")]
{ id.inner.as_ref().into() }
}
}
impl #impl_generics std::clone::Clone for #owned_ty { impl #impl_generics std::clone::Clone for #owned_ty {
fn clone(&self) -> Self { fn clone(&self) -> Self {
(&*self.inner).into() (&*self.inner).into()