diff --git a/ruma-identifiers/src/macros.rs b/ruma-identifiers/src/macros.rs index 4cd2c097..3615d0c5 100644 --- a/ruma-identifiers/src/macros.rs +++ b/ruma-identifiers/src/macros.rs @@ -92,11 +92,31 @@ macro_rules! common_impls { self.full_id.as_bytes() } } + + doc_concat! { + #[doc = concat!("Converts this `", stringify!($id), "` into a `String`")] + pub fn into_string(self) -> String { + self.full_id.into() + } + } + + doc_concat! { + #[doc = concat!("Converts this `", stringify!($id), "` into a `Vec`")] + pub fn into_bytes(self) -> Vec { + Box::<[u8]>::from(self.full_id).into() + } + } } impl ::std::convert::From<$id> for ::std::string::String { fn from(id: $id) -> Self { - id.full_id.into() + id.into_string() + } + } + + impl ::std::convert::From<$id> for ::std::vec::Vec { + fn from(id: $id) -> Self { + id.into_bytes() } }