Implement `Arbitrary` for `&'a Script`
The `Arbitrary` trait allows zero-copy implementations for borrowed types, so this adds the implementation for borrowed `Script`.
This commit is contained in:
parent
bca2864084
commit
b7e2af1b6b
|
@ -4,6 +4,9 @@ use core::ops::{
|
|||
Bound, Index, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive,
|
||||
};
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
use arbitrary::{Arbitrary, Unstructured};
|
||||
|
||||
use super::ScriptBuf;
|
||||
use crate::prelude::{Box, ToOwned, Vec};
|
||||
|
||||
|
@ -132,6 +135,14 @@ impl Script {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
impl<'a> Arbitrary<'a> for &'a Script {
|
||||
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
|
||||
let v = <&'a [u8]>::arbitrary(u)?;
|
||||
Ok(Script::from_bytes(v))
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! delegate_index {
|
||||
($($type:ty),* $(,)?) => {
|
||||
$(
|
||||
|
|
Loading…
Reference in New Issue