MCPcopy Create free account
hub / github.com/arkworks-rs/poly-commit / OptionalRng

Class OptionalRng

poly-commit/src/optional_rng.rs:10–10  ·  view source on GitHub ↗

`OptionalRng` is a hack that is necessary because `Option<&mut R>` is not implicitly reborrowed like `&mut R` is. This causes problems when a variable of type `Option<&mut R>` is moved (eg, in a loop). To overcome this, we define the wrapper `OptionalRng` here that can be borrowed mutably, without fear of being moved.

Source from the content-addressed store, hash-verified

8/// To overcome this, we define the wrapper `OptionalRng` here that can be borrowed
9/// mutably, without fear of being moved.
10pub struct OptionalRng<R>(pub Option<R>);
11
12impl<R: RngCore> RngCore for OptionalRng<R> {
13 #[inline]

Callers 6

batch_openMethod · 0.85
commitMethod · 0.85
commitMethod · 0.85
batch_openMethod · 0.85
commitMethod · 0.85
commitMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected