Deprecate to_vec in favour of to_bytes
Currently we have to method names for the same thing "copy this object into a vector". The library is easier to use if we are uniform and just use one. Elect to use `to_bytes`, for context see discussion in PR #2585.
This commit is contained in:
parent
89d6991cf1
commit
eda61ddfef
|
@ -284,7 +284,11 @@ impl Witness {
|
|||
}
|
||||
|
||||
/// Convenience method to create an array of byte-arrays from this witness.
|
||||
pub fn to_vec(&self) -> Vec<Vec<u8>> { self.iter().map(|s| s.to_vec()).collect() }
|
||||
pub fn to_bytes(&self) -> Vec<Vec<u8>> { self.iter().map(|s| s.to_vec()).collect() }
|
||||
|
||||
/// Convenience method to create an array of byte-arrays from this witness.
|
||||
#[deprecated(since = "TBD", note = "Use to_bytes instead")]
|
||||
pub fn to_vec(&self) -> Vec<Vec<u8>> { self.to_bytes() }
|
||||
|
||||
/// Returns `true` if the witness contains no element.
|
||||
pub fn is_empty(&self) -> bool { self.witness_elements == 0 }
|
||||
|
|
|
@ -57,7 +57,7 @@ impl Signature {
|
|||
///
|
||||
/// Note: this performs an extra heap allocation, you might prefer the
|
||||
/// [`serialize`](Self::serialize) method instead.
|
||||
pub fn to_vec(self) -> Vec<u8> {
|
||||
pub fn to_bytes(self) -> Vec<u8> {
|
||||
self.signature
|
||||
.serialize_der()
|
||||
.iter()
|
||||
|
@ -66,6 +66,10 @@ impl Signature {
|
|||
.collect()
|
||||
}
|
||||
|
||||
/// Serializes an ECDSA signature (inner secp256k1 signature in DER format) into `Vec`.
|
||||
#[deprecated(since = "TBD", note = "Use to_bytes instead")]
|
||||
pub fn to_vec(self) -> Vec<u8> { self.to_bytes() }
|
||||
|
||||
/// Serializes an ECDSA signature (inner secp256k1 signature in DER format) to a `writer`.
|
||||
#[inline]
|
||||
pub fn serialize_to_writer<W: Write + ?Sized>(&self, writer: &mut W) -> Result<(), io::Error> {
|
||||
|
|
|
@ -47,7 +47,7 @@ impl Signature {
|
|||
/// Serialize Signature
|
||||
///
|
||||
/// Note: this allocates on the heap, prefer [`serialize`](Self::serialize) if vec is not needed.
|
||||
pub fn to_vec(self) -> Vec<u8> {
|
||||
pub fn to_bytes(self) -> Vec<u8> {
|
||||
let mut ser_sig = self.signature.as_ref().to_vec();
|
||||
if self.sighash_type == TapSighashType::Default {
|
||||
// default sighash type, don't add extra sighash byte
|
||||
|
@ -57,6 +57,10 @@ impl Signature {
|
|||
ser_sig
|
||||
}
|
||||
|
||||
/// Serialize Signature
|
||||
#[deprecated(since = "TBD", note = "Use to_bytes instead")]
|
||||
pub fn to_vec(self) -> Vec<u8> { self.to_bytes() }
|
||||
|
||||
/// Serializes the signature to `writer`.
|
||||
#[inline]
|
||||
pub fn serialize_to_writer<W: Write + ?Sized>(&self, writer: &mut W) -> Result<(), io::Error> {
|
||||
|
|
Loading…
Reference in New Issue