Compare commits

...

3 Commits

Author SHA1 Message Date
Kris Nuttycombe bbd4e9c243
Merge pull request #26 from nuttycom/add_const_accountid_ctr
Add `AccountId::const_from_u32`
2025-05-15 14:25:14 -06:00
Kris Nuttycombe 372a4887f0 Add `AccountId::const_from_u32` 2025-04-15 11:53:10 -06:00
Kris Nuttycombe 92aec1f9f4
Merge pull request #25 from zcash/release/v0.2.0
Release zip32 version 0.2.0
2025-02-20 14:03:25 -07:00
2 changed files with 15 additions and 0 deletions

View File

@ -7,6 +7,9 @@ and this library adheres to Rust's notion of
## [Unreleased]
### Added
- `zip32::AccountId::const_from_u32`
## [0.2.0] - 2025-02-20
### Added

View File

@ -73,6 +73,18 @@ impl AccountId {
pub fn next(&self) -> Option<Self> {
Self::try_from(self.0 + 1).ok()
}
/// Constant function to construct an account ID from a u32.
///
/// # Panics
/// Panics if the provided value is >= 2^31
pub const fn const_from_u32(value: u32) -> Self {
if value < (1 << 31) {
Self(value)
} else {
panic!("Account IDs must be in the range 0..2^31");
}
}
}
/// The error type returned when a checked integral type conversion fails.