Add to_vec and deprecate to_bytes for array types
For the array wrapper types (eg `ShortId`) created with the `impl_array_newtype` macro deprecated the `to_bytes` function and add a `to_vec` function. Discussed and decided upon in issue: #3025
This commit is contained in:
parent
a6b7ab32a8
commit
dc2ca785d2
|
@ -300,13 +300,18 @@ macro_rules! impl_array_newtype {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Copies the underlying bytes into a new `Vec`.
|
||||||
|
#[inline]
|
||||||
|
pub fn to_vec(&self) -> alloc::vec::Vec<u8> { self.0.to_vec() }
|
||||||
|
|
||||||
/// Returns a slice of the underlying bytes.
|
/// Returns a slice of the underlying bytes.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_bytes(&self) -> &[u8] { &self.0 }
|
pub fn as_bytes(&self) -> &[u8] { &self.0 }
|
||||||
|
|
||||||
/// Copies the underlying bytes into a new `Vec`.
|
/// Copies the underlying bytes into a new `Vec`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_bytes(&self) -> alloc::vec::Vec<u8> { self.0.to_vec() }
|
#[deprecated(since = "TBD", note = "use to_vec instead")]
|
||||||
|
pub fn to_bytes(&self) -> alloc::vec::Vec<u8> { self.to_vec() }
|
||||||
|
|
||||||
/// Converts the object to a raw pointer.
|
/// Converts the object to a raw pointer.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Reference in New Issue