Move from Field::negate to Neg operator

This commit is contained in:
Jack Grigg
2019-12-12 22:52:17 +00:00
parent 4a3350bc31
commit 91c32f1c7c
26 changed files with 175 additions and 189 deletions

View File

@@ -11,7 +11,7 @@ use rand_core::RngCore;
use std::error::Error;
use std::fmt;
use std::io::{self, Read, Write};
use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
use std::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
/// This trait represents an element of a field.
pub trait Field:
@@ -27,6 +27,7 @@ pub trait Field:
+ Add<Output = Self>
+ Sub<Output = Self>
+ Mul<Output = Self>
+ Neg<Output = Self>
+ for<'a> Add<&'a Self, Output = Self>
+ for<'a> Mul<&'a Self, Output = Self>
+ for<'a> Sub<&'a Self, Output = Self>
@@ -55,9 +56,6 @@ pub trait Field:
/// Doubles this element.
fn double(&mut self);
/// Negates this element.
fn negate(&mut self);
/// Computes the multiplicative inverse of this element, if nonzero.
fn inverse(&self) -> Option<Self>;