mirror of https://github.com/zcash/zip32.git
Fix clippy lint
This commit is contained in:
parent
4365a10003
commit
ceb970c211
|
@ -20,3 +20,7 @@ subtle = "2.2.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_matches = "1.5"
|
assert_matches = "1.5"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["std"]
|
||||||
|
std = []
|
||||||
|
|
20
src/lib.rs
20
src/lib.rs
|
@ -7,6 +7,9 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(rustdoc::broken_intra_doc_links)]
|
#![deny(rustdoc::broken_intra_doc_links)]
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
extern crate std;
|
||||||
|
|
||||||
use memuse::{self, DynamicUsage};
|
use memuse::{self, DynamicUsage};
|
||||||
use subtle::{Choice, ConditionallySelectable};
|
use subtle::{Choice, ConditionallySelectable};
|
||||||
|
|
||||||
|
@ -138,7 +141,7 @@ impl DiversifierIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Increments this index, failing on overflow.
|
/// Increments this index, failing on overflow.
|
||||||
pub fn increment(&mut self) -> Result<(), ()> {
|
pub fn increment(&mut self) -> Result<(), DiversifierIndexOverflowError> {
|
||||||
for k in 0..11 {
|
for k in 0..11 {
|
||||||
self.0[k] = self.0[k].wrapping_add(1);
|
self.0[k] = self.0[k].wrapping_add(1);
|
||||||
if self.0[k] != 0 {
|
if self.0[k] != 0 {
|
||||||
|
@ -147,10 +150,23 @@ impl DiversifierIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Overflow
|
// Overflow
|
||||||
Err(())
|
Err(DiversifierIndexOverflowError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The error type returned when a [`DiversifierIndex`] increment fails.
|
||||||
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
pub struct DiversifierIndexOverflowError;
|
||||||
|
|
||||||
|
impl core::fmt::Display for DiversifierIndexOverflowError {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
write!(f, "DiversifierIndex increment overflowed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
impl std::error::Error for DiversifierIndexOverflowError {}
|
||||||
|
|
||||||
/// The scope of a viewing key or address.
|
/// The scope of a viewing key or address.
|
||||||
///
|
///
|
||||||
/// A "scope" narrows the visibility or usage to a level below "full".
|
/// A "scope" narrows the visibility or usage to a level below "full".
|
||||||
|
|
Loading…
Reference in New Issue