identifiers: Add more conversion methods and a trait impl
This commit is contained in:
parent
d883debe07
commit
0dcbec5fa7
@ -92,11 +92,31 @@ macro_rules! common_impls {
|
|||||||
self.full_id.as_bytes()
|
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<u8>`")]
|
||||||
|
pub fn into_bytes(self) -> Vec<u8> {
|
||||||
|
Box::<[u8]>::from(self.full_id).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::convert::From<$id> for ::std::string::String {
|
impl ::std::convert::From<$id> for ::std::string::String {
|
||||||
fn from(id: $id) -> Self {
|
fn from(id: $id) -> Self {
|
||||||
id.full_id.into()
|
id.into_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::std::convert::From<$id> for ::std::vec::Vec<u8> {
|
||||||
|
fn from(id: $id) -> Self {
|
||||||
|
id.into_bytes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user