From ca1735f24cb1273c3afe8044068fbf2c80d534da Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 7 Aug 2024 14:39:57 +1000 Subject: [PATCH 1/7] Separate POD methods We want to move `Script` as a plain old data type to `primitives`. Step 1: Move the methods that will go to `primitives` to a separate impl block. --- bitcoin/src/blockdata/script/borrowed.rs | 58 ++++++++++++------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/bitcoin/src/blockdata/script/borrowed.rs b/bitcoin/src/blockdata/script/borrowed.rs index 82b65be53..4e0d017fe 100644 --- a/bitcoin/src/blockdata/script/borrowed.rs +++ b/bitcoin/src/blockdata/script/borrowed.rs @@ -110,6 +110,36 @@ impl Script { #[inline] pub fn as_mut_bytes(&mut self) -> &mut [u8] { &mut self.0 } + /// Returns the length in bytes of the script. + #[inline] + pub fn len(&self) -> usize { self.0.len() } + + /// Returns whether the script is the empty script. + #[inline] + pub fn is_empty(&self) -> bool { self.0.is_empty() } + + /// Returns a copy of the script data. + #[inline] + pub fn to_bytes(&self) -> Vec { self.0.to_owned() } + + /// Converts a [`Box