From 3af3239ad03d52dd7b58dba293e2ff991bf8cb96 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 31 Oct 2024 14:34:18 +1100 Subject: [PATCH] script: Re-order functions We want our code to be easy to read and our APIs discoverable, for those of us who read source files the layout matters. Put the constructors and getters at the top of the impl block. Code move only, no logic changes. --- primitives/src/script/borrowed.rs | 16 ++++----- primitives/src/script/owned.rs | 60 +++++++++++++++---------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/primitives/src/script/borrowed.rs b/primitives/src/script/borrowed.rs index 03f596a27..86857deb8 100644 --- a/primitives/src/script/borrowed.rs +++ b/primitives/src/script/borrowed.rs @@ -97,14 +97,6 @@ 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_vec(&self) -> Vec { self.0.to_owned() } @@ -114,6 +106,14 @@ impl Script { #[deprecated(since = "TBD", note = "use to_vec instead")] pub fn to_bytes(&self) -> Vec { self.to_vec() } + /// 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() } + /// Converts a [`Box