Skip to content

Commit f90c288

Browse files
committed
make arbitrary generic over size
1 parent 68db238 commit f90c288

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/arb.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rand::{
77
use crate::MultihashGeneric;
88

99
/// Generates a random valid multihash.
10-
impl Arbitrary for MultihashGeneric<64> {
10+
impl<const S: usize> Arbitrary for MultihashGeneric<S> {
1111
fn arbitrary<G: Gen>(g: &mut G) -> Self {
1212
// In real world lower multihash codes are more likely to happen, hence distribute them
1313
// with bias towards smaller values.
@@ -25,9 +25,9 @@ impl Arbitrary for MultihashGeneric<64> {
2525
_ => unreachable!(),
2626
};
2727

28-
// Maximum size is 64 byte due to the `U64` generic
29-
let size = g.gen_range(0, 64);
30-
let mut data = [0; 64];
28+
// Maximum size is S byte due to the generic.
29+
let size = g.gen_range(0, S);
30+
let mut data = [0; S];
3131
g.fill_bytes(&mut data);
3232
MultihashGeneric::wrap(code, &data[..size]).unwrap()
3333
}

0 commit comments

Comments
 (0)