mirror of https://github.com/zcash/zip32.git
Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
bbd4e9c243 | |
|
372a4887f0 | |
|
92aec1f9f4 |
|
@ -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
|
||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue