Force public structures to implement Debug

Closes #23.
This commit is contained in:
str4d 2017-09-26 15:59:50 +01:00
parent 57de78f4f1
commit 39920186b3
No known key found for this signature in database
GPG Key ID: 665DBCD284F7DAFF
3 changed files with 33 additions and 2 deletions

View File

@ -584,6 +584,7 @@ macro_rules! curve_impl {
pub mod g1 {
use rand::{Rand, Rng};
use std::fmt;
use super::g2::G2Affine;
use super::super::{Bls12, Fq, Fr, FrRepr, FqRepr, Fq12};
use ::{CurveProjective, CurveAffine, PrimeField, SqrtField, PrimeFieldRepr, Field, BitIterator, EncodedPoint, GroupDecodingError, Engine};
@ -611,6 +612,12 @@ pub mod g1 {
}
}
impl fmt::Debug for G1Uncompressed {
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
self.0[..].fmt(formatter)
}
}
impl EncodedPoint for G1Uncompressed {
type Affine = G1Affine;
@ -713,6 +720,12 @@ pub mod g1 {
}
}
impl fmt::Debug for G1Compressed {
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
self.0[..].fmt(formatter)
}
}
impl EncodedPoint for G1Compressed {
type Affine = G1Affine;
@ -879,7 +892,7 @@ pub mod g1 {
}
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct G1Prepared(pub(crate) G1Affine);
impl G1Prepared {
@ -1137,6 +1150,7 @@ pub mod g1 {
pub mod g2 {
use rand::{Rand, Rng};
use std::fmt;
use super::super::{Bls12, Fq2, Fr, Fq, FrRepr, FqRepr, Fq12};
use super::g1::G1Affine;
use ::{CurveProjective, CurveAffine, PrimeField, SqrtField, PrimeFieldRepr, Field, BitIterator, EncodedPoint, GroupDecodingError, Engine};
@ -1164,6 +1178,12 @@ pub mod g2 {
}
}
impl fmt::Debug for G2Uncompressed {
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
self.0[..].fmt(formatter)
}
}
impl EncodedPoint for G2Uncompressed {
type Affine = G2Affine;
@ -1278,6 +1298,12 @@ pub mod g2 {
}
}
impl fmt::Debug for G2Compressed {
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
self.0[..].fmt(formatter)
}
}
impl EncodedPoint for G2Compressed {
type Affine = G2Affine;
@ -1459,7 +1485,7 @@ pub mod g2 {
}
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct G2Prepared {
pub(crate) coeffs: Vec<(Fq2, Fq2, Fq2)>,
pub(crate) infinity: bool

View File

@ -21,6 +21,7 @@ use super::{Engine, CurveAffine, Field, BitIterator};
const BLS_X: u64 = 0xd201000000010000;
const BLS_X_IS_NEGATIVE: bool = true;
#[derive(Debug)]
pub struct Bls12;
impl Engine for Bls12 {

View File

@ -13,6 +13,9 @@
#![cfg_attr(feature = "clippy", allow(too_many_arguments))]
#![cfg_attr(feature = "clippy", allow(unreadable_literal))]
// Force public structures to implement Debug
#![deny(missing_debug_implementations)]
// The compiler provides `test` (on nightly) for benchmarking tools, but
// it's hidden behind a feature flag. Enable it if we're testing.
#![cfg_attr(test, feature(test))]
@ -563,6 +566,7 @@ pub trait PrimeField: Field
fn root_of_unity() -> Self;
}
#[derive(Debug)]
pub struct BitIterator<E> {
t: E,
n: usize