-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
Description
The code at https://github.com/freedomlayer/offst/blob/master/components/crypto/src/rand.rs is very repetitive. Example:
impl RandGen for Salt {
fn rand_gen(crypt_rng: &impl CryptoRandom) -> Self {
let mut res = Self::default();
crypt_rng.fill(&mut res).unwrap();
res
}
}
impl RandGen for InvoiceId {
fn rand_gen(crypt_rng: &impl CryptoRandom) -> Self {
let mut res = Self::default();
crypt_rng.fill(&mut res).unwrap();
res
}
}
// ...We can create a macro that does this automatically, possibly a macro that that can be used like this:
derive_rand_gen!(InvoiceId);
This issue is suitable for beginners with Rust and with the Offst project.