remove unnecessary generics on RandGenerators (#142)

This commit is contained in:
Mrmaxmeier 2021-06-01 17:26:36 +02:00 committed by GitHub
parent c90604f123
commit 1b755036ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
//! Generators may generate bytes or, in general, data, for inputs. //! Generators may generate bytes or, in general, data, for inputs.
use alloc::vec::Vec; use alloc::vec::Vec;
use core::{cmp::min, marker::PhantomData}; use core::cmp::min;
use crate::{ use crate::{
bolts::rands::Rand, bolts::rands::Rand,
@ -27,15 +27,11 @@ where
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
/// Generates random bytes /// Generates random bytes
pub struct RandBytesGenerator<R> pub struct RandBytesGenerator {
where
R: Rand,
{
max_size: usize, max_size: usize,
phantom: PhantomData<R>,
} }
impl<R> Generator<BytesInput, R> for RandBytesGenerator<R> impl<R> Generator<BytesInput, R> for RandBytesGenerator
where where
R: Rand, R: Rand,
{ {
@ -55,28 +51,21 @@ where
} }
} }
impl<R> RandBytesGenerator<R> impl RandBytesGenerator {
where
R: Rand,
{
/// Returns a new [`RandBytesGenerator`], generating up to `max_size` random bytes. /// Returns a new [`RandBytesGenerator`], generating up to `max_size` random bytes.
#[must_use] #[must_use]
pub fn new(max_size: usize) -> Self { pub fn new(max_size: usize) -> Self {
Self { Self { max_size }
max_size,
phantom: PhantomData,
}
} }
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
/// Generates random printable characters /// Generates random printable characters
pub struct RandPrintablesGenerator<R> { pub struct RandPrintablesGenerator {
max_size: usize, max_size: usize,
phantom: PhantomData<R>,
} }
impl<R> Generator<BytesInput, R> for RandPrintablesGenerator<R> impl<R> Generator<BytesInput, R> for RandPrintablesGenerator
where where
R: Rand, R: Rand,
{ {
@ -97,16 +86,10 @@ where
} }
} }
impl<R> RandPrintablesGenerator<R> impl RandPrintablesGenerator {
where
R: Rand,
{
/// Creates a new [`RandPrintablesGenerator`], generating up to `max_size` random printable characters. /// Creates a new [`RandPrintablesGenerator`], generating up to `max_size` random printable characters.
#[must_use] #[must_use]
pub fn new(max_size: usize) -> Self { pub fn new(max_size: usize) -> Self {
Self { Self { max_size }
max_size,
phantom: PhantomData,
}
} }
} }