mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-30 20:11:23 +00:00
Make Field::double take &self and return Self
This commit is contained in:
@@ -1040,12 +1040,16 @@ fn prime_field_impl(
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn double(&mut self) {
|
||||
fn double(&self) -> Self {
|
||||
let mut ret = *self;
|
||||
|
||||
// This cannot exceed the backing capacity.
|
||||
self.0.mul2();
|
||||
ret.0.mul2();
|
||||
|
||||
// However, it may need to be reduced.
|
||||
self.reduce();
|
||||
ret.reduce();
|
||||
|
||||
ret
|
||||
}
|
||||
|
||||
fn inverse(&self) -> Option<Self> {
|
||||
|
@@ -54,7 +54,8 @@ pub trait Field:
|
||||
fn square(&mut self);
|
||||
|
||||
/// Doubles this element.
|
||||
fn double(&mut self);
|
||||
#[must_use]
|
||||
fn double(&self) -> Self;
|
||||
|
||||
/// Computes the multiplicative inverse of this element, if nonzero.
|
||||
fn inverse(&self) -> Option<Self>;
|
||||
|
Reference in New Issue
Block a user