}</pre><divclass='docblock'><p>A random number generator.</p>
</div>
<h2id='required-methods'>Required Methods</h2>
<divclass='methods'>
<h3id='tymethod.next_u32'class='method stab '><code>fn <ahref='#tymethod.next_u32'class='fnname'>next_u32</a>(&mut self) -><aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.u32.html'>u32</a></code></h3><divclass='docblock'><p>Return the next random u32.</p>
<p>This rarely needs to be called directly, prefer <code>r.gen()</code> to
<code>r.next_u32()</code>.</p>
</div></div>
<h2id='provided-methods'>Provided Methods</h2>
<divclass='methods'>
<h3id='method.next_u64'class='method stab '><code>fn <ahref='#method.next_u64'class='fnname'>next_u64</a>(&mut self) -><aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.u64.html'>u64</a></code></h3><divclass='docblock'><p>Return the next random u64.</p>
<p>By default this is implemented in terms of <code>next_u32</code>. An
implementation of this trait must provide at least one of
these two methods. Similarly to <code>next_u32</code>, this rarely needs
to be called directly, prefer <code>r.gen()</code> to <code>r.next_u64()</code>.</p>
</div><h3id='method.next_f32'class='method stab '><code>fn <ahref='#method.next_f32'class='fnname'>next_f32</a>(&mut self) -><aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.f32.html'>f32</a></code></h3><divclass='docblock'><p>Return the next random f32 selected from the half-open
interval <code>[0, 1)</code>.</p>
<p>This uses a technique described by Saito and Matsumoto at
MCQMC'08. Given that the IEEE floating point numbers are
uniformly distributed over [1,2), we generate a number in
this range and then offset it onto the range [0,1). Our
choice of bits (masking v. shifting) is arbitrary and
should be immaterial for high quality generators. For low
quality generators (ex. LCG), prefer bitshifting due to
correlation between sequential low order bits.</p>
<p>See:
A PRNG specialized in double precision floating point numbers using
<p>By default this is implemented in terms of <code>next_u32</code>, but a
random number generator which can generate numbers satisfying
the requirements directly can overload this for performance.
It is required that the return value lies in <code>[0, 1)</code>.</p>
<p>See <code>Closed01</code> for the closed interval <code>[0,1]</code>, and
<code>Open01</code> for the open interval <code>(0,1)</code>.</p>
</div><h3id='method.next_f64'class='method stab '><code>fn <ahref='#method.next_f64'class='fnname'>next_f64</a>(&mut self) -><aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.f64.html'>f64</a></code></h3><divclass='docblock'><p>Return the next random f64 selected from the half-open
interval <code>[0, 1)</code>.</p>
<p>By default this is implemented in terms of <code>next_u64</code>, but a
random number generator which can generate numbers satisfying
the requirements directly can overload this for performance.
It is required that the return value lies in <code>[0, 1)</code>.</p>
<p>See <code>Closed01</code> for the closed interval <code>[0,1]</code>, and
<code>Open01</code> for the open interval <code>(0,1)</code>.</p>
</div><h3id='method.fill_bytes'class='method stab '><code>fn <ahref='#method.fill_bytes'class='fnname'>fill_bytes</a>(&mut self, dest: <aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&mut [</a><aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>)</code></h3><divclass='docblock'><p>Fill <code>dest</code> with random data.</p>
<p>This has a default implementation in terms of <code>next_u64</code> and
<code>next_u32</code>, but should be overridden by implementations that
offer a more efficient solution than just calling those
methods repeatedly.</p>
<p>This method does <em>not</em> have a requirement to bear any fixed
relationship to the other methods, for example, it does <em>not</em>
have to result in the same output as progressively filling
<code>dest</code> with <code>self.gen::<u8>()</code>, and any such behaviour should
not be relied upon.</p>
<p>This method should guarantee that <code>dest</code> is entirely filled
with new data, and may panic if this is impossible
(e.g. reading past the end of a file that is being used as the
</div><h3id='method.gen'class='method stab '><code>fn <ahref='#method.gen'class='fnname'>gen</a><T: <aclass='trait'href='../rand/trait.Rand.html'title='rand::Rand'>Rand</a>>(&mut self) -> T <spanclass='where'>where Self: <aclass='trait'href='https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html'title='core::marker::Sized'>Sized</a></span></code></h3><divclass='docblock'><p>Return a random value of a <code>Rand</code> type.</p>
</div><h3id='method.gen_iter'class='method stab '><code>fn <ahref='#method.gen_iter'class='fnname'>gen_iter</a><'a, T: <aclass='trait'href='../rand/trait.Rand.html'title='rand::Rand'>Rand</a>>(&'a mut self) -><aclass='struct'href='../rand/struct.Generator.html'title='rand::Generator'>Generator</a><'a, T, Self><spanclass='where'>where Self: <aclass='trait'href='https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html'title='core::marker::Sized'>Sized</a></span></code></h3><divclass='docblock'><p>Return an iterator that will yield an infinite number of randomly
</div><h3id='method.gen_range'class='method stab '><code>fn <ahref='#method.gen_range'class='fnname'>gen_range</a><T: <aclass='trait'href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html'title='core::cmp::PartialOrd'>PartialOrd</a> + <aclass='trait'href='../rand/distributions/range/trait.SampleRange.html'title='rand::distributions::range::SampleRange'>SampleRange</a>>(&mut self, low: T, high: T) -> T <spanclass='where'>where Self: <aclass='trait'href='https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html'title='core::marker::Sized'>Sized</a></span></code></h3><divclass='docblock'><p>Generate a random value in the range [<code>low</code>, <code>high</code>).</p>
<p>This is a convenience wrapper around
<code>distributions::Range</code>. If this function will be called
repeatedly with the same arguments, one should use <code>Range</code>, as
that will amortize the computations that allow for perfect
uniformity, as they only happen on initialization.</p>
</div><h3id='method.gen_weighted_bool'class='method stab '><code>fn <ahref='#method.gen_weighted_bool'class='fnname'>gen_weighted_bool</a>(&mut self, n: <aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.u32.html'>u32</a>) -><aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a><spanclass='where'>where Self: <aclass='trait'href='https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html'title='core::marker::Sized'>Sized</a></span></code></h3><divclass='docblock'><p>Return a bool with a 1 in n chance of true</p>
</div><h3id='method.gen_ascii_chars'class='method stab '><code>fn <ahref='#method.gen_ascii_chars'class='fnname'>gen_ascii_chars</a><'a>(&'a mut self) -><aclass='struct'href='../rand/struct.AsciiGenerator.html'title='rand::AsciiGenerator'>AsciiGenerator</a><'a, Self><spanclass='where'>where Self: <aclass='trait'href='https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html'title='core::marker::Sized'>Sized</a></span></code></h3><divclass='docblock'><p>Return an iterator of random characters from the set A-Z,a-z,0-9.</p>
</div><h3id='method.choose'class='method stab '><code>fn <ahref='#method.choose'class='fnname'>choose</a><'a, T>(&mut self, values: <aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&'a [</a>T<aclass='primitive'href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>) -><aclass='enum'href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html'title='core::option::Option'>Option</a><&'a T><spanclass='where'>where Self: <aclass='trait'href='https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html'title='core::marker::Sized'>Sized</a></span></code></h3><divclass='docblock'><p>Return a random element from <code>values</code>.</p>
<p>Return <code>None</code> if <code>values</code> is empty.</p>
<li><code>impl Rng for <aclass='struct'href='../rand/isaac/struct.IsaacRng.html'title='rand::isaac::IsaacRng'>IsaacRng</a></code></li>
<li><code>impl Rng for <aclass='struct'href='../rand/isaac/struct.Isaac64Rng.html'title='rand::isaac::Isaac64Rng'>Isaac64Rng</a></code></li>
<li><code>impl Rng for <aclass='struct'href='../rand/chacha/struct.ChaChaRng.html'title='rand::chacha::ChaChaRng'>ChaChaRng</a></code></li>
<li><code>impl<R: <aclass='trait'href='../rand/trait.Rng.html'title='rand::Rng'>Rng</a>, Rsdr: <aclass='trait'href='../rand/reseeding/trait.Reseeder.html'title='rand::reseeding::Reseeder'>Reseeder</a><R>> Rng for <aclass='struct'href='../rand/reseeding/struct.ReseedingRng.html'title='rand::reseeding::ReseedingRng'>ReseedingRng</a><R, Rsdr></code></li>
<li><code>impl Rng for <aclass='struct'href='../rand/os/struct.OsRng.html'title='rand::os::OsRng'>OsRng</a></code></li>
<li><code>impl<R: <aclass='trait'href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html'title='std::io::Read'>Read</a>> Rng for <aclass='struct'href='../rand/read/struct.ReadRng.html'title='rand::read::ReadRng'>ReadRng</a><R></code></li>
<li><code>impl<'a, R: ?<aclass='trait'href='https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html'title='core::marker::Sized'>Sized</a>> Rng for &'a mut R <spanclass='where'>where R: <aclass='trait'href='../rand/trait.Rng.html'title='rand::Rng'>Rng</a></span></code></li>
<li><code>impl<R: ?<aclass='trait'href='https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html'title='core::marker::Sized'>Sized</a>> Rng for <aclass='struct'href='https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html'title='alloc::boxed::Box'>Box</a><R><spanclass='where'>where R: <aclass='trait'href='../rand/trait.Rng.html'title='rand::Rng'>Rng</a></span></code></li>
<li><code>impl Rng for <aclass='struct'href='../rand/struct.XorShiftRng.html'title='rand::XorShiftRng'>XorShiftRng</a></code></li>
<li><code>impl Rng for <aclass='struct'href='../rand/struct.StdRng.html'title='rand::StdRng'>StdRng</a></code></li>
<li><code>impl Rng for <aclass='struct'href='../rand/struct.ThreadRng.html'title='rand::ThreadRng'>ThreadRng</a></code></li>