Take self directly in into_* functions

This commit is contained in:
Jack Grigg 2019-08-02 12:03:38 +01:00
parent fe93f2ff6b
commit 9016548698
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
3 changed files with 8 additions and 6 deletions

View File

@ -404,7 +404,7 @@ pub fn blake2s<E: Engine, CS: ConstraintSystem<E>>(
)?; )?;
} }
Ok(h.iter().flat_map(|b| b.into_bits()).collect()) Ok(h.into_iter().flat_map(|b| b.into_bits()).collect())
} }
#[cfg(test)] #[cfg(test)]

View File

@ -72,8 +72,10 @@ impl UInt32 {
Ok(UInt32 { bits, value }) Ok(UInt32 { bits, value })
} }
pub fn into_bits_be(&self) -> Vec<Boolean> { pub fn into_bits_be(self) -> Vec<Boolean> {
self.bits.iter().rev().cloned().collect() let mut ret = self.bits;
ret.reverse();
ret
} }
pub fn from_bits_be(bits: &[Boolean]) -> Self { pub fn from_bits_be(bits: &[Boolean]) -> Self {
@ -101,8 +103,8 @@ impl UInt32 {
} }
/// Turns this `UInt32` into its little-endian byte order representation. /// Turns this `UInt32` into its little-endian byte order representation.
pub fn into_bits(&self) -> Vec<Boolean> { pub fn into_bits(self) -> Vec<Boolean> {
self.bits.clone() self.bits
} }
/// Converts a little-endian byte order representation of bits into a /// Converts a little-endian byte order representation of bits into a

View File

@ -508,7 +508,7 @@ impl<E: JubjubEngine> MontgomeryPoint<E> {
/// a point in the birationally equivalent twisted /// a point in the birationally equivalent twisted
/// Edwards curve. /// Edwards curve.
pub fn into_edwards<CS>( pub fn into_edwards<CS>(
&self, self,
mut cs: CS, mut cs: CS,
params: &E::Params, params: &E::Params,
) -> Result<EdwardsPoint<E>, SynthesisError> ) -> Result<EdwardsPoint<E>, SynthesisError>