Merge pull request #441 from str4d/memuse-0.2

`impl memuse::DynamicUsage for Amount`
This commit is contained in:
Kris Nuttycombe 2021-09-14 16:14:57 -06:00 committed by GitHub
commit a3df9dd47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -51,6 +51,8 @@ and this library adheres to Rust's notion of
data, as described above.
- `zcash_primitives::serialize` has been factored out as a new `zcash_encoding`
crate, which can be found in the `components` directory.
- `zcash_primitives::transaction::components::Amount` now implements
`memuse::DynamicUsage`, to enable `orchard::Bundle<_, Amount>::dynamic_usage`.
### Changed
- MSRV is now 1.51.0.

View File

@ -33,6 +33,7 @@ incrementalmerkletree = "0.1"
jubjub = "0.8"
lazy_static = "1"
log = "0.4"
memuse = "0.2"
nonempty = "0.7"
orchard = "0.0"
pasta_curves = "0.2"

View File

@ -23,6 +23,18 @@ pub const DEFAULT_FEE: Amount = Amount(1000);
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub struct Amount(i64);
impl memuse::DynamicUsage for Amount {
#[inline(always)]
fn dynamic_usage(&self) -> usize {
0
}
#[inline(always)]
fn dynamic_usage_bounds(&self) -> (usize, Option<usize>) {
(0, Some(0))
}
}
impl Amount {
/// Returns a zero-valued Amount.
pub const fn zero() -> Self {