Skip to content

Commit a522ee4

Browse files
committed
Merge #113: Mark const methods
c0c62db chore: Mark methods as const (Christian Lewe) 509a855 fix: Clippy (Christian Lewe) Pull request description: Mark some key methods as const. ACKs for top commit: apoelstra: ACK c0c62db; successfully ran local tests Tree-SHA512: e854f3a5cbc4d842fab58db7afc5ab84231f8d5263fc2ed78f4dc6c1570558b71a6535fab372d9175844df19c0b60f751c9b5b0135f3f83568c1d07c908d5311
2 parents ab4cea1 + c0c62db commit a522ee4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/num.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,14 @@ impl U256 {
225225
/// Create a 256-bit unsigned integer from a byte array.
226226
///
227227
/// The byte array is in Big Endian order.
228-
pub fn from_byte_array(bytes: [u8; 32]) -> Self {
228+
pub const fn from_byte_array(bytes: [u8; 32]) -> Self {
229229
Self(bytes)
230230
}
231231

232232
/// Convert the integer to a byte array.
233233
///
234234
/// The byte array is in Big Endian order.
235-
pub fn to_byte_array(self) -> [u8; 32] {
235+
pub const fn to_byte_array(self) -> [u8; 32] {
236236
self.0
237237
}
238238
}

src/value.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl UIntValue {
155155
let mut byte = 0u8;
156156
for _ in 0..8 {
157157
let bit = padded_bits.next().unwrap();
158-
byte = byte << 1 | if bit == '1' { 1 } else { 0 };
158+
byte = (byte << 1) | if bit == '1' { 1 } else { 0 };
159159
}
160160
bytes.push(byte);
161161
}
@@ -607,12 +607,12 @@ impl From<UIntValue> for Value {
607607

608608
impl Value {
609609
/// Access the inner structure of the value.
610-
pub fn inner(&self) -> &ValueInner {
610+
pub const fn inner(&self) -> &ValueInner {
611611
&self.inner
612612
}
613613

614614
/// Access the type of the value.
615-
pub fn ty(&self) -> &ResolvedType {
615+
pub const fn ty(&self) -> &ResolvedType {
616616
&self.ty
617617
}
618618

0 commit comments

Comments
 (0)