-
Notifications
You must be signed in to change notification settings - Fork 180
Closed as not planned
Description
Please implement the recommended traits for the enum PaddingScheme.
Clone is missing from PaddingScheme. Please fix this.
While copy may not be possible due to problems when copying RngCore--namely that an accidental copy may generate the same numbers--, clone is an important implementation which is advised by the creators of rand. With the added implementation of box-clone on Box<dyn DynDigest> and on Box<dyn RngCore>, written out in full bellow, it should be possible to derive Clone on PaddingScheme.
for DynDigest:
pub trait DynDigest {
...
}
pub trait DynDigestBoxClone {
fn clone_dyn_digest(&self) -> Box<dyn DynDigest>;
}
impl<T> DynDigestBoxClone for T where T: 'static + DynDigest + Clone {
fn clone_dyn_digest(&self) -> Box<dyn DynDigest> {
Box::new(self.clone())
}
}
impl Clone for Box<dyn DynDigest> {
fn clone(&self) -> Self {
self.clone_dyn_digest()
}
}and the same for Box<dyn RngCore>:
use rand::RngCore;
pub trait RngCoreClone: RngCore {
fn clone_rng_core(&self) -> Box<dyn RngCoreClone>;
}
impl<T: 'static + RngCore + Clone> RngCoreClone for T {
fn clone_rng_core(&self) -> Box<dyn RngCoreClone> {
Box::new(self.clone())
}
}
impl Clone for Box<dyn RngCoreClone> {
fn clone(&self) -> Box<dyn RngCoreClone> {
self.clone_rng_core()
}
}and switch to using Box<dyn RngCoreClone> rather than Box<dyn RngCore>.
Thanks.
Best regards,
littleTitan
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels