deploy: de38ae62916547ad097c066f94a32e9ba7790eeb

This commit is contained in:
NotAShelf 2025-02-05 00:10:33 +00:00
commit 9a86359447
28502 changed files with 1261284 additions and 0 deletions

View file

@ -0,0 +1,82 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A distribution uniformly sampling numbers within a given range."><title>rand::distributions::uniform - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="rand" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../../rand/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../rand/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../../rand/index.html">rand</a><span class="version">0.8.5</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module uniform</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example-usage" title="Example usage">Example usage</a></li><li><a href="#extending-uniform-to-support-a-custom-type" title="Extending `Uniform` to support a custom type">Extending <code>Uniform</code> to support a custom type</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In rand::<wbr>distributions</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../index.html">rand</a>::<wbr><a href="../index.html">distributions</a></span><h1>Module <span>uniform</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/rand/distributions/uniform.rs.html#10-1658">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A distribution uniformly sampling numbers within a given range.</p>
<p><a href="../struct.Uniform.html" title="struct rand::distributions::Uniform"><code>Uniform</code></a> is the standard distribution to sample uniformly from a range;
e.g. <code>Uniform::new_inclusive(1, 6)</code> can sample integers from 1 to 6, like a
standard die. <a href="../../trait.Rng.html#method.gen_range" title="method rand::Rng::gen_range"><code>Rng::gen_range</code></a> supports any type supported by
<a href="../struct.Uniform.html" title="struct rand::distributions::Uniform"><code>Uniform</code></a>.</p>
<p>This distribution is provided with support for several primitive types
(all integer and floating-point types) as well as <a href="https://doc.rust-lang.org/1.84.1/core/time/struct.Duration.html" title="struct core::time::Duration"><code>std::time::Duration</code></a>,
and supports extension to user-defined types via a type-specific <em>back-end</em>
implementation.</p>
<p>The types <a href="struct.UniformInt.html" title="struct rand::distributions::uniform::UniformInt"><code>UniformInt</code></a>, <a href="struct.UniformFloat.html" title="struct rand::distributions::uniform::UniformFloat"><code>UniformFloat</code></a> and <a href="struct.UniformDuration.html" title="struct rand::distributions::uniform::UniformDuration"><code>UniformDuration</code></a> are the
back-ends supporting sampling from primitive integer and floating-point
ranges as well as from <a href="https://doc.rust-lang.org/1.84.1/core/time/struct.Duration.html" title="struct core::time::Duration"><code>std::time::Duration</code></a>; these types do not normally
need to be used directly (unless implementing a derived back-end).</p>
<h2 id="example-usage"><a class="doc-anchor" href="#example-usage">§</a>Example usage</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand::{Rng, thread_rng};
<span class="kw">use </span>rand::distributions::Uniform;
<span class="kw">let </span><span class="kw-2">mut </span>rng = thread_rng();
<span class="kw">let </span>side = Uniform::new(-<span class="number">10.0</span>, <span class="number">10.0</span>);
<span class="comment">// sample between 1 and 10 points
</span><span class="kw">for _ in </span><span class="number">0</span>..rng.gen_range(<span class="number">1</span>..=<span class="number">10</span>) {
<span class="comment">// sample a point from the square with sides -10 - 10 in two dimensions
</span><span class="kw">let </span>(x, y) = (rng.sample(side), rng.sample(side));
<span class="macro">println!</span>(<span class="string">"Point: {}, {}"</span>, x, y);
}</code></pre></div>
<h2 id="extending-uniform-to-support-a-custom-type"><a class="doc-anchor" href="#extending-uniform-to-support-a-custom-type">§</a>Extending <code>Uniform</code> to support a custom type</h2>
<p>To extend <a href="../struct.Uniform.html" title="struct rand::distributions::Uniform"><code>Uniform</code></a> to support your own types, write a back-end which
implements the <a href="trait.UniformSampler.html" title="trait rand::distributions::uniform::UniformSampler"><code>UniformSampler</code></a> trait, then implement the <a href="trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform"><code>SampleUniform</code></a>
helper trait to “register” your back-end. See the <code>MyF32</code> example below.</p>
<p>At a minimum, the back-end needs to store any parameters needed for sampling
(e.g. the target range) and implement <code>new</code>, <code>new_inclusive</code> and <code>sample</code>.
Those methods should include an assert to check the range is valid (i.e.
<code>low &lt; high</code>). The example below merely wraps another back-end.</p>
<p>The <code>new</code>, <code>new_inclusive</code> and <code>sample_single</code> functions use arguments of
type SampleBorrow<X> in order to support passing in values by reference or
by value. In the implementation of these functions, you can choose to
simply use the reference returned by <a href="trait.SampleBorrow.html#tymethod.borrow" title="method rand::distributions::uniform::SampleBorrow::borrow"><code>SampleBorrow::borrow</code></a>, or you can choose
to copy or clone the value, whatever is appropriate for your type.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>rand::distributions::uniform::{Uniform, SampleUniform,
UniformSampler, UniformFloat, SampleBorrow};
<span class="kw">struct </span>MyF32(f32);
<span class="attr">#[derive(Clone, Copy, Debug)]
</span><span class="kw">struct </span>UniformMyF32(UniformFloat&lt;f32&gt;);
<span class="kw">impl </span>UniformSampler <span class="kw">for </span>UniformMyF32 {
<span class="kw">type </span>X = MyF32;
<span class="kw">fn </span>new&lt;B1, B2&gt;(low: B1, high: B2) -&gt; <span class="self">Self
</span><span class="kw">where </span>B1: SampleBorrow&lt;<span class="self">Self</span>::X&gt; + Sized,
B2: SampleBorrow&lt;<span class="self">Self</span>::X&gt; + Sized
{
UniformMyF32(UniformFloat::&lt;f32&gt;::new(low.borrow().<span class="number">0</span>, high.borrow().<span class="number">0</span>))
}
<span class="kw">fn </span>new_inclusive&lt;B1, B2&gt;(low: B1, high: B2) -&gt; <span class="self">Self
</span><span class="kw">where </span>B1: SampleBorrow&lt;<span class="self">Self</span>::X&gt; + Sized,
B2: SampleBorrow&lt;<span class="self">Self</span>::X&gt; + Sized
{
UniformMyF32(UniformFloat::&lt;f32&gt;::new_inclusive(
low.borrow().<span class="number">0</span>,
high.borrow().<span class="number">0</span>,
))
}
<span class="kw">fn </span>sample&lt;R: Rng + <span class="question-mark">?</span>Sized&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, rng: <span class="kw-2">&amp;mut </span>R) -&gt; <span class="self">Self</span>::X {
MyF32(<span class="self">self</span>.<span class="number">0</span>.sample(rng))
}
}
<span class="kw">impl </span>SampleUniform <span class="kw">for </span>MyF32 {
<span class="kw">type </span>Sampler = UniformMyF32;
}
<span class="kw">let </span>(low, high) = (MyF32(<span class="number">17.0f32</span>), MyF32(<span class="number">22.0f32</span>));
<span class="kw">let </span>uniform = Uniform::new(low, high);
<span class="kw">let </span>x = uniform.sample(<span class="kw-2">&amp;mut </span>thread_rng());</code></pre></div>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Uniform.html" title="struct rand::distributions::uniform::Uniform">Uniform</a></div><div class="desc docblock-short">Sample values uniformly between two bounds.</div></li><li><div class="item-name"><a class="struct" href="struct.UniformChar.html" title="struct rand::distributions::uniform::UniformChar">Uniform<wbr>Char</a></div><div class="desc docblock-short">The back-end implementing <a href="trait.UniformSampler.html" title="trait rand::distributions::uniform::UniformSampler"><code>UniformSampler</code></a> for <code>char</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.UniformDuration.html" title="struct rand::distributions::uniform::UniformDuration">Uniform<wbr>Duration</a></div><div class="desc docblock-short">The back-end implementing <a href="trait.UniformSampler.html" title="trait rand::distributions::uniform::UniformSampler"><code>UniformSampler</code></a> for <code>Duration</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.UniformFloat.html" title="struct rand::distributions::uniform::UniformFloat">Uniform<wbr>Float</a></div><div class="desc docblock-short">The back-end implementing <a href="trait.UniformSampler.html" title="trait rand::distributions::uniform::UniformSampler"><code>UniformSampler</code></a> for floating-point types.</div></li><li><div class="item-name"><a class="struct" href="struct.UniformInt.html" title="struct rand::distributions::uniform::UniformInt">Uniform<wbr>Int</a></div><div class="desc docblock-short">The back-end implementing <a href="trait.UniformSampler.html" title="trait rand::distributions::uniform::UniformSampler"><code>UniformSampler</code></a> for integer types.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">Sample<wbr>Borrow</a></div><div class="desc docblock-short">Helper trait similar to <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow"><code>Borrow</code></a> but implemented
only for SampleUniform and references to SampleUniform in
order to resolve ambiguity issues.</div></li><li><div class="item-name"><a class="trait" href="trait.SampleRange.html" title="trait rand::distributions::uniform::SampleRange">Sample<wbr>Range</a></div><div class="desc docblock-short">Range that supports generating a single sample efficiently.</div></li><li><div class="item-name"><a class="trait" href="trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">Sample<wbr>Uniform</a></div><div class="desc docblock-short">Helper trait for creating objects using the correct implementation of
<a href="trait.UniformSampler.html" title="trait rand::distributions::uniform::UniformSampler"><code>UniformSampler</code></a> for the sampling type.</div></li><li><div class="item-name"><a class="trait" href="trait.UniformSampler.html" title="trait rand::distributions::uniform::UniformSampler">Uniform<wbr>Sampler</a></div><div class="desc docblock-short">Helper trait handling actual uniform sampling.</div></li></ul></section></div></main></body></html>

View file

@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"struct":["Uniform","UniformChar","UniformDuration","UniformFloat","UniformInt"],"trait":["SampleBorrow","SampleRange","SampleUniform","UniformSampler"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,10 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Helper trait similar to `Borrow` but implemented only for SampleUniform and references to SampleUniform in order to resolve ambiguity issues."><title>SampleBorrow in rand::distributions::uniform - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="rand" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../../rand/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../rand/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../../rand/index.html">rand</a><span class="version">0.8.5</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Sample<wbr>Borrow</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.borrow" title="borrow">borrow</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-SampleBorrow%3CBorrowed%3E-for-%26Borrowed" title="&#38;&#39;a Borrowed">&#38;&#39;a Borrowed</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In rand::<wbr>distributions::<wbr>uniform</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../index.html">rand</a>::<wbr><a href="../index.html">distributions</a>::<wbr><a href="index.html">uniform</a></span><h1>Trait <span class="trait">SampleBorrow</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/rand/distributions/uniform.rs.html#322-327">Source</a> </span></div><pre class="rust item-decl"><code>pub trait SampleBorrow&lt;Borrowed&gt; {
// Required method
fn <a href="#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;Borrowed</a>;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Helper trait similar to <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow"><code>Borrow</code></a> but implemented
only for SampleUniform and references to SampleUniform in
order to resolve ambiguity issues.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.borrow" class="method"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#326">Source</a><h4 class="code-header">fn <a href="#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;Borrowed</a></h4></section></summary><div class="docblock"><p>Immutably borrows from an owned value. See <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" title="method core::borrow::Borrow::borrow"><code>Borrow::borrow</code></a></p>
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-SampleBorrow%3CBorrowed%3E-for-%26Borrowed" class="impl"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#336-343">Source</a><a href="#impl-SampleBorrow%3CBorrowed%3E-for-%26Borrowed" class="anchor">§</a><h3 class="code-header">impl&lt;'a, Borrowed&gt; <a class="trait" href="trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;Borrowed&gt; for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;'a Borrowed</a><div class="where">where
Borrowed: <a class="trait" href="trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a>,</div></h3></section></summary><div class="impl-items"><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#340-342">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;Borrowed</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-SampleBorrow%3CBorrowed%3E-for-Borrowed" class="impl"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#328-335">Source</a><a href="#impl-SampleBorrow%3CBorrowed%3E-for-Borrowed" class="anchor">§</a><h3 class="code-header">impl&lt;Borrowed&gt; <a class="trait" href="trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;Borrowed&gt; for Borrowed<div class="where">where
Borrowed: <a class="trait" href="trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a>,</div></h3></section></div><script src="../../../trait.impl/rand/distributions/uniform/trait.SampleBorrow.js" async></script></section></div></main></body></html>

View file

@ -0,0 +1,10 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Range that supports generating a single sample efficiently."><title>SampleRange in rand::distributions::uniform - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="rand" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../../rand/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../rand/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../../rand/index.html">rand</a><span class="version">0.8.5</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Sample<wbr>Range</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.is_empty" title="is_empty">is_empty</a></li><li><a href="#tymethod.sample_single" title="sample_single">sample_single</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-SampleRange%3CT%3E-for-Range%3CT%3E" title="Range&#60;T&#62;">Range&#60;T&#62;</a></li><li><a href="#impl-SampleRange%3CT%3E-for-RangeInclusive%3CT%3E" title="RangeInclusive&#60;T&#62;">RangeInclusive&#60;T&#62;</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In rand::<wbr>distributions::<wbr>uniform</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../index.html">rand</a>::<wbr><a href="../index.html">distributions</a>::<wbr><a href="index.html">uniform</a></span><h1>Trait <span class="trait">SampleRange</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/rand/distributions/uniform.rs.html#349-355">Source</a> </span></div><pre class="rust item-decl"><code>pub trait SampleRange&lt;T&gt; {
// Required methods
fn <a href="#tymethod.sample_single" class="fn">sample_single</a>&lt;R: <a class="trait" href="../../trait.RngCore.html" title="trait rand::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;mut R</a>) -&gt; T;
<span class="item-spacer"></span> fn <a href="#tymethod.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a>;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Range that supports generating a single sample efficiently.</p>
<p>Any type implementing this trait can be used to specify the sampled range
for <code>Rng::gen_range</code>.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.sample_single" class="method"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#351">Source</a><h4 class="code-header">fn <a href="#tymethod.sample_single" class="fn">sample_single</a>&lt;R: <a class="trait" href="../../trait.RngCore.html" title="trait rand::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;mut R</a>) -&gt; T</h4></section></summary><div class="docblock"><p>Generate a sample from the given range.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.is_empty" class="method"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#354">Source</a><h4 class="code-header">fn <a href="#tymethod.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Check whether the range is empty.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.1/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-SampleRange%3CT%3E-for-Range%3CT%3E" class="impl"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#357-367">Source</a><a href="#impl-SampleRange%3CT%3E-for-Range%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&gt; <a class="trait" href="trait.SampleRange.html" title="trait rand::distributions::uniform::SampleRange">SampleRange</a>&lt;T&gt; for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a>&lt;T&gt;</h3></section></summary><div class="impl-items"><section id="method.sample_single" class="method trait-impl"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#359-361">Source</a><a href="#method.sample_single" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.sample_single" class="fn">sample_single</a>&lt;R: <a class="trait" href="../../trait.RngCore.html" title="trait rand::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;mut R</a>) -&gt; T</h4></section><section id="method.is_empty" class="method trait-impl"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#364-366">Source</a><a href="#method.is_empty" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-SampleRange%3CT%3E-for-RangeInclusive%3CT%3E" class="impl"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#369-379">Source</a><a href="#impl-SampleRange%3CT%3E-for-RangeInclusive%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&gt; <a class="trait" href="trait.SampleRange.html" title="trait rand::distributions::uniform::SampleRange">SampleRange</a>&lt;T&gt; for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/ops/range/struct.RangeInclusive.html" title="struct core::ops::range::RangeInclusive">RangeInclusive</a>&lt;T&gt;</h3></section></summary><div class="impl-items"><section id="method.sample_single-1" class="method trait-impl"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#371-373">Source</a><a href="#method.sample_single-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.sample_single" class="fn">sample_single</a>&lt;R: <a class="trait" href="../../trait.RngCore.html" title="trait rand::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;mut R</a>) -&gt; T</h4></section><section id="method.is_empty-1" class="method trait-impl"><a class="src rightside" href="../../../src/rand/distributions/uniform.rs.html#376-378">Source</a><a href="#method.is_empty-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../../trait.impl/rand/distributions/uniform/trait.SampleRange.js" data-ignore-extern-crates="core" async></script></section></div></main></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long