Merge rust-bitcoin/rust-bitcoin#1391: `Witness` conversion trait implementations

f0e72dbbfe `Witness` conversion trait impls (Noah Lanson)

Pull request description:

  #1385

  Implemented:
  - `From<Vec<Vec<u8>>>`
  - `From<&[&[u8]]>`
  - `From<&[Vec<u8>]>`
  - `From<Vec<&[u8]>>`

ACKs for top commit:
  tcharding:
    ACK f0e72dbbfe
  Kixunil:
    ACK f0e72dbbfe
  apoelstra:
    ACK f0e72dbbfe

Tree-SHA512: 87e52c62fb76dc41b9b26cc3faf0046598219b7737287961665ccce006e466ca3616b757b3eeff310127c10c1685d2fd897cfc035f1b4acc1fb48ed963e45930
This commit is contained in:
Andrew Poelstra 2022-11-17 02:57:02 +00:00
commit b4a9a7a72a
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 24 additions and 0 deletions

View File

@ -457,6 +457,30 @@ impl<'de> serde::Deserialize<'de> for Witness {
} }
} }
impl From<Vec<Vec<u8>>> for Witness {
fn from(vec: Vec<Vec<u8>>) -> Self {
Witness::from_slice(&vec)
}
}
impl From<&[&[u8]]> for Witness {
fn from(slice: &[&[u8]]) -> Self {
Witness::from_slice(slice)
}
}
impl From<&[Vec<u8>]> for Witness {
fn from(slice: &[Vec<u8>]) -> Self {
Witness::from_slice(slice)
}
}
impl From<Vec<&[u8]>> for Witness {
fn from(vec: Vec<&[u8]>) -> Self {
Witness::from_slice(&vec)
}
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;