Skip to content

Commit 232cb1a

Browse files
committed
Merge rust-bitcoin#5245: Convert functions to const in 1.0 crates
ec9ec52 primitives: Convert various functions to const (Mitchell Bagot) 98b5777 units: Convert various functions to const (Mitchell Bagot) Pull request description: For similar reasons as rust-bitcoin#5231, functions that are unlikely to later be non-const should be converted to const for potential runtime performance gains. This includes getters, setters and zero-argument constructors like `new()`. Convert zero argument constructor functions to const in primitives and units. ACKs for top commit: apoelstra: ACK ec9ec52; successfully ran local tests; though could probably be squashed tcharding: ACK ec9ec52 Tree-SHA512: a9ac0b99e2ea5b612dbc6c8f82ca0cb11e87d848bb628f9e11b55b0025a380625440b2c18750db00708ab2f01e49509caccf5477d22fb43b1fdacc18f8eb24d7
2 parents 3501653 + ec9ec52 commit 232cb1a

File tree

18 files changed

+59
-59
lines changed

18 files changed

+59
-59
lines changed

api/primitives/all-features.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,24 +1231,36 @@ pub const fn bitcoin_primitives::WitnessMerkleNode::to_byte_array(self) -> [u8;
12311231
pub const fn bitcoin_primitives::Wtxid::as_byte_array(&self) -> &[u8; 32]
12321232
pub const fn bitcoin_primitives::Wtxid::from_byte_array(bytes: [u8; 32]) -> Self
12331233
pub const fn bitcoin_primitives::Wtxid::to_byte_array(self) -> [u8; 32]
1234+
pub const fn bitcoin_primitives::block::BlockHashDecoder::new() -> Self
12341235
pub const fn bitcoin_primitives::block::Version::from_consensus(v: i32) -> Self
1236+
pub const fn bitcoin_primitives::block::Version::to_consensus(self) -> i32
1237+
pub const fn bitcoin_primitives::block::VersionDecoder::new() -> Self
1238+
pub const fn bitcoin_primitives::pow::CompactTarget::to_consensus(self) -> u32
1239+
pub const fn bitcoin_primitives::pow::CompactTargetDecoder::new() -> Self
12351240
pub const fn bitcoin_primitives::script::Script<T>::as_bytes(&self) -> &[u8]
12361241
pub const fn bitcoin_primitives::script::Script<T>::from_bytes(bytes: &[u8]) -> &Self
12371242
pub const fn bitcoin_primitives::script::Script<T>::is_empty(&self) -> bool
12381243
pub const fn bitcoin_primitives::script::Script<T>::len(&self) -> usize
12391244
pub const fn bitcoin_primitives::script::Script<T>::new() -> &'static Self
12401245
pub const fn bitcoin_primitives::script::ScriptBuf<T>::from_bytes(bytes: alloc::vec::Vec<u8>) -> Self
12411246
pub const fn bitcoin_primitives::script::ScriptBuf<T>::new() -> Self
1247+
pub const fn bitcoin_primitives::script::ScriptBufDecoder<T>::new() -> Self
12421248
pub const fn bitcoin_primitives::script::ScriptHash::as_byte_array(&self) -> &[u8; 20]
12431249
pub const fn bitcoin_primitives::script::ScriptHash::from_byte_array(bytes: [u8; 20]) -> Self
12441250
pub const fn bitcoin_primitives::script::ScriptHash::to_byte_array(self) -> [u8; 20]
12451251
pub const fn bitcoin_primitives::script::WScriptHash::as_byte_array(&self) -> &[u8; 32]
12461252
pub const fn bitcoin_primitives::script::WScriptHash::from_byte_array(bytes: [u8; 32]) -> Self
12471253
pub const fn bitcoin_primitives::script::WScriptHash::to_byte_array(self) -> [u8; 32]
1254+
pub const fn bitcoin_primitives::transaction::OutPointDecoder::new() -> Self
1255+
pub const fn bitcoin_primitives::transaction::TransactionDecoder::new() -> Self
1256+
pub const fn bitcoin_primitives::transaction::TxMerkleNodeDecoder::new() -> Self
12481257
pub const fn bitcoin_primitives::transaction::Version::is_standard(self) -> bool
12491258
pub const fn bitcoin_primitives::transaction::Version::maybe_non_standard(version: u32) -> Self
12501259
pub const fn bitcoin_primitives::transaction::Version::to_u32(self) -> u32
1260+
pub const fn bitcoin_primitives::transaction::VersionDecoder::new() -> Self
1261+
pub const fn bitcoin_primitives::witness::Witness::len(&self) -> usize
12511262
pub const fn bitcoin_primitives::witness::Witness::new() -> Self
1263+
pub const fn bitcoin_primitives::witness::WitnessDecoder::new() -> Self
12521264
pub enum bitcoin_primitives::BlockChecked
12531265
pub enum bitcoin_primitives::BlockUnchecked
12541266
pub enum bitcoin_primitives::block::Checked
@@ -1414,7 +1426,6 @@ pub fn bitcoin_primitives::block::BlockEncoder<'e>::advance(&mut self) -> bool
14141426
pub fn bitcoin_primitives::block::BlockEncoder<'e>::current_chunk(&self) -> &[u8]
14151427
pub fn bitcoin_primitives::block::BlockHashDecoder::default() -> Self
14161428
pub fn bitcoin_primitives::block::BlockHashDecoder::end(self) -> core::result::Result<Self::Output, Self::Error>
1417-
pub fn bitcoin_primitives::block::BlockHashDecoder::new() -> Self
14181429
pub fn bitcoin_primitives::block::BlockHashDecoder::push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<bool, Self::Error>
14191430
pub fn bitcoin_primitives::block::BlockHashDecoder::read_limit(&self) -> usize
14201431
pub fn bitcoin_primitives::block::BlockHashDecoderError::clone(&self) -> bitcoin_primitives::block::BlockHashDecoderError
@@ -1470,10 +1481,8 @@ pub fn bitcoin_primitives::block::Version::hash<__H: core::hash::Hasher>(&self,
14701481
pub fn bitcoin_primitives::block::Version::is_signalling_soft_fork(self, bit: u8) -> bool
14711482
pub fn bitcoin_primitives::block::Version::partial_cmp(&self, other: &bitcoin_primitives::block::Version) -> core::option::Option<core::cmp::Ordering>
14721483
pub fn bitcoin_primitives::block::Version::serialize<__S>(&self, __serializer: __S) -> core::result::Result<<__S as serde::ser::Serializer>::Ok, <__S as serde::ser::Serializer>::Error> where __S: serde::ser::Serializer
1473-
pub fn bitcoin_primitives::block::Version::to_consensus(self) -> i32
14741484
pub fn bitcoin_primitives::block::VersionDecoder::default() -> Self
14751485
pub fn bitcoin_primitives::block::VersionDecoder::end(self) -> core::result::Result<Self::Output, Self::Error>
1476-
pub fn bitcoin_primitives::block::VersionDecoder::new() -> Self
14771486
pub fn bitcoin_primitives::block::VersionDecoder::push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<bool, Self::Error>
14781487
pub fn bitcoin_primitives::block::VersionDecoder::read_limit(&self) -> usize
14791488
pub fn bitcoin_primitives::block::VersionDecoderError::clone(&self) -> bitcoin_primitives::block::VersionDecoderError
@@ -1497,11 +1506,9 @@ pub fn bitcoin_primitives::pow::CompactTarget::from_consensus(bits: u32) -> Self
14971506
pub fn bitcoin_primitives::pow::CompactTarget::hash<__H: core::hash::Hasher>(&self, state: &mut __H)
14981507
pub fn bitcoin_primitives::pow::CompactTarget::partial_cmp(&self, other: &bitcoin_primitives::pow::CompactTarget) -> core::option::Option<core::cmp::Ordering>
14991508
pub fn bitcoin_primitives::pow::CompactTarget::serialize<__S>(&self, __serializer: __S) -> core::result::Result<<__S as serde::ser::Serializer>::Ok, <__S as serde::ser::Serializer>::Error> where __S: serde::ser::Serializer
1500-
pub fn bitcoin_primitives::pow::CompactTarget::to_consensus(self) -> u32
15011509
pub fn bitcoin_primitives::pow::CompactTarget::to_hex(self) -> alloc::string::String
15021510
pub fn bitcoin_primitives::pow::CompactTargetDecoder::default() -> Self
15031511
pub fn bitcoin_primitives::pow::CompactTargetDecoder::end(self) -> core::result::Result<Self::Output, Self::Error>
1504-
pub fn bitcoin_primitives::pow::CompactTargetDecoder::new() -> Self
15051512
pub fn bitcoin_primitives::pow::CompactTargetDecoder::push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<bool, Self::Error>
15061513
pub fn bitcoin_primitives::pow::CompactTargetDecoder::read_limit(&self) -> usize
15071514
pub fn bitcoin_primitives::pow::CompactTargetDecoderError::clone(&self) -> bitcoin_primitives::pow::CompactTargetDecoderError
@@ -1584,7 +1591,6 @@ pub fn bitcoin_primitives::script::ScriptBuf<T>::to_hex(&self) -> alloc::string:
15841591
pub fn bitcoin_primitives::script::ScriptBuf<T>::with_capacity(capacity: usize) -> Self
15851592
pub fn bitcoin_primitives::script::ScriptBufDecoder<T>::default() -> Self
15861593
pub fn bitcoin_primitives::script::ScriptBufDecoder<T>::end(self) -> core::result::Result<Self::Output, Self::Error>
1587-
pub fn bitcoin_primitives::script::ScriptBufDecoder<T>::new() -> Self
15881594
pub fn bitcoin_primitives::script::ScriptBufDecoder<T>::push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<bool, Self::Error>
15891595
pub fn bitcoin_primitives::script::ScriptBufDecoder<T>::read_limit(&self) -> usize
15901596
pub fn bitcoin_primitives::script::ScriptBufDecoderError::clone(&self) -> bitcoin_primitives::script::ScriptBufDecoderError
@@ -1672,7 +1678,6 @@ pub fn bitcoin_primitives::transaction::OutPoint::partial_cmp(&self, other: &bit
16721678
pub fn bitcoin_primitives::transaction::OutPoint::serialize<S>(&self, serializer: S) -> core::result::Result<<S as serde::ser::Serializer>::Ok, <S as serde::ser::Serializer>::Error> where S: serde::ser::Serializer
16731679
pub fn bitcoin_primitives::transaction::OutPointDecoder::default() -> Self
16741680
pub fn bitcoin_primitives::transaction::OutPointDecoder::end(self) -> core::result::Result<Self::Output, Self::Error>
1675-
pub fn bitcoin_primitives::transaction::OutPointDecoder::new() -> Self
16761681
pub fn bitcoin_primitives::transaction::OutPointDecoder::push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<bool, Self::Error>
16771682
pub fn bitcoin_primitives::transaction::OutPointDecoder::read_limit(&self) -> usize
16781683
pub fn bitcoin_primitives::transaction::OutPointDecoderError::clone(&self) -> bitcoin_primitives::transaction::OutPointDecoderError
@@ -1700,7 +1705,6 @@ pub fn bitcoin_primitives::transaction::Transaction::hash<__H: core::hash::Hashe
17001705
pub fn bitcoin_primitives::transaction::Transaction::partial_cmp(&self, other: &Self) -> core::option::Option<core::cmp::Ordering>
17011706
pub fn bitcoin_primitives::transaction::TransactionDecoder::default() -> Self
17021707
pub fn bitcoin_primitives::transaction::TransactionDecoder::end(self) -> core::result::Result<Self::Output, Self::Error>
1703-
pub fn bitcoin_primitives::transaction::TransactionDecoder::new() -> Self
17041708
pub fn bitcoin_primitives::transaction::TransactionDecoder::push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<bool, Self::Error>
17051709
pub fn bitcoin_primitives::transaction::TransactionDecoder::read_limit(&self) -> usize
17061710
pub fn bitcoin_primitives::transaction::TransactionDecoderError::clone(&self) -> bitcoin_primitives::transaction::TransactionDecoderError
@@ -1736,7 +1740,6 @@ pub fn bitcoin_primitives::transaction::TxInEncoder<'e>::advance(&mut self) -> b
17361740
pub fn bitcoin_primitives::transaction::TxInEncoder<'e>::current_chunk(&self) -> &[u8]
17371741
pub fn bitcoin_primitives::transaction::TxMerkleNodeDecoder::default() -> Self
17381742
pub fn bitcoin_primitives::transaction::TxMerkleNodeDecoder::end(self) -> core::result::Result<Self::Output, Self::Error>
1739-
pub fn bitcoin_primitives::transaction::TxMerkleNodeDecoder::new() -> Self
17401743
pub fn bitcoin_primitives::transaction::TxMerkleNodeDecoder::push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<bool, Self::Error>
17411744
pub fn bitcoin_primitives::transaction::TxMerkleNodeDecoder::read_limit(&self) -> usize
17421745
pub fn bitcoin_primitives::transaction::TxMerkleNodeDecoderError::clone(&self) -> bitcoin_primitives::transaction::TxMerkleNodeDecoderError
@@ -1777,7 +1780,6 @@ pub fn bitcoin_primitives::transaction::Version::partial_cmp(&self, other: &bitc
17771780
pub fn bitcoin_primitives::transaction::Version::serialize<__S>(&self, __serializer: __S) -> core::result::Result<<__S as serde::ser::Serializer>::Ok, <__S as serde::ser::Serializer>::Error> where __S: serde::ser::Serializer
17781781
pub fn bitcoin_primitives::transaction::VersionDecoder::default() -> Self
17791782
pub fn bitcoin_primitives::transaction::VersionDecoder::end(self) -> core::result::Result<Self::Output, Self::Error>
1780-
pub fn bitcoin_primitives::transaction::VersionDecoder::new() -> Self
17811783
pub fn bitcoin_primitives::transaction::VersionDecoder::push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<bool, Self::Error>
17821784
pub fn bitcoin_primitives::transaction::VersionDecoder::read_limit(&self) -> usize
17831785
pub fn bitcoin_primitives::transaction::VersionDecoderError::clone(&self) -> bitcoin_primitives::transaction::VersionDecoderError
@@ -1836,15 +1838,13 @@ pub fn bitcoin_primitives::witness::Witness::index(&self, index: usize) -> &Self
18361838
pub fn bitcoin_primitives::witness::Witness::is_empty(&self) -> bool
18371839
pub fn bitcoin_primitives::witness::Witness::iter(&self) -> bitcoin_primitives::witness::Iter<'_>
18381840
pub fn bitcoin_primitives::witness::Witness::last(&self) -> core::option::Option<&[u8]>
1839-
pub fn bitcoin_primitives::witness::Witness::len(&self) -> usize
18401841
pub fn bitcoin_primitives::witness::Witness::partial_cmp(&self, other: &bitcoin_primitives::witness::Witness) -> core::option::Option<core::cmp::Ordering>
18411842
pub fn bitcoin_primitives::witness::Witness::push<T: core::convert::AsRef<[u8]>>(&mut self, new_element: T)
18421843
pub fn bitcoin_primitives::witness::Witness::serialize<S>(&self, serializer: S) -> core::result::Result<<S as serde::ser::Serializer>::Ok, <S as serde::ser::Serializer>::Error> where S: serde::ser::Serializer
18431844
pub fn bitcoin_primitives::witness::Witness::size(&self) -> usize
18441845
pub fn bitcoin_primitives::witness::Witness::to_vec(&self) -> alloc::vec::Vec<alloc::vec::Vec<u8>>
18451846
pub fn bitcoin_primitives::witness::WitnessDecoder::default() -> Self
18461847
pub fn bitcoin_primitives::witness::WitnessDecoder::end(self) -> core::result::Result<Self::Output, Self::Error>
1847-
pub fn bitcoin_primitives::witness::WitnessDecoder::new() -> Self
18481848
pub fn bitcoin_primitives::witness::WitnessDecoder::push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<bool, Self::Error>
18491849
pub fn bitcoin_primitives::witness::WitnessDecoder::read_limit(&self) -> usize
18501850
pub fn bitcoin_primitives::witness::WitnessDecoderError::clone(&self) -> bitcoin_primitives::witness::WitnessDecoderError

0 commit comments

Comments
 (0)