Add `Builder::with_capacity()`
This commit is contained in:
parent
e492f94289
commit
d003d48592
|
@ -21,6 +21,10 @@ impl Builder {
|
|||
#[inline]
|
||||
pub const fn new() -> Self { Builder(ScriptBuf::new(), None) }
|
||||
|
||||
/// Constructs a new empty script builder with at least the specified capacity.
|
||||
#[inline]
|
||||
pub fn with_capacity(capacity: usize) -> Self { Builder(ScriptBuf::with_capacity(capacity), None) }
|
||||
|
||||
/// Returns the length in bytes of the script.
|
||||
pub fn len(&self) -> usize { self.0.len() }
|
||||
|
||||
|
|
|
@ -209,6 +209,13 @@ fn script_builder() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_builder_with_capacity() {
|
||||
let script = Builder::with_capacity(42);
|
||||
|
||||
assert!(script.into_script().capacity() >= 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_generators() {
|
||||
let pubkey = "0234e6a79c5359c613762d537e0e19d86c77c1666d8c9ab050f23acd198e97f93e"
|
||||
|
|
Loading…
Reference in New Issue