scad 1.2.2

A crate for generating OpenSCAD models using rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
<!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="API documentation for the Rust `rand` crate.">
    <meta name="keywords" content="rust, rustlang, rust-lang, rand">

    <title>rand - Rust</title>

    <link rel="stylesheet" type="text/css" href="../rustdoc.css">
    <link rel="stylesheet" type="text/css" href="../main.css">
    

    <link rel="shortcut icon" href="https://www.rust-lang.org/favicon.ico">
    
</head>
<body class="rustdoc">
    <!--[if lte IE 8]>
    <div class="warning">
        This old browser is unsupported and will most likely display funky
        things.
    </div>
    <![endif]-->

    

    <nav class="sidebar">
        <a href='../rand/index.html'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk.png' alt='logo' width='100'></a>
        <p class='location'></p><script>window.sidebarCurrent = {name: 'rand', ty: 'mod', relpath: '../'};</script>
    </nav>

    <nav class="sub">
        <form class="search-form js-only">
            <div class="search-container">
                <input class="search-input" name="search"
                       autocomplete="off"
                       placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
                       type="search">
            </div>
        </form>
    </nav>

    <section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Crate <a class='mod' href=''>rand</a></span><span class='out-of-band'><span id='render-detail'>
                   <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
                       [<span class='inner'>&#x2212;</span>]
                   </a>
               </span><a id='src-0' class='srclink' href='../src/rand/lib.rs.html#11-1226' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>Utilities for random number generation</p>

<p>The key functions are <code>random()</code> and <code>Rng::gen()</code>. These are polymorphic and
so can be used to generate any type that implements <code>Rand</code>. Type inference
means that often a simple call to <code>rand::random()</code> or <code>rng.gen()</code> will
suffice, but sometimes an annotation is required, e.g.
<code>rand::random::&lt;f64&gt;()</code>.</p>

<p>See the <code>distributions</code> submodule for sampling random numbers from
distributions like normal and exponential.</p>

<h1 id='usage' class='section-header'><a href='#usage'>Usage</a></h1>
<p>This crate is <a href="https://crates.io/crates/rand">on crates.io</a> and can be
used by adding <code>rand</code> to the dependencies in your project&#39;s <code>Cargo.toml</code>.</p>

<pre><code class="language-toml">[dependencies]
rand = &quot;0.3&quot;
</code></pre>

<p>and this to your crate root:</p>

<pre class='rust rust-example-rendered'>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rand</span>;<a class='test-arrow' target='_blank' href=''>Run</a></pre>

<h1 id='thread-local-rng' class='section-header'><a href='#thread-local-rng'>Thread-local RNG</a></h1>
<p>There is built-in support for a RNG associated with each thread stored
in thread-local storage. This RNG can be accessed via <code>thread_rng</code>, or
used implicitly via <code>random</code>. This RNG is normally randomly seeded
from an operating-system source of randomness, e.g. <code>/dev/urandom</code> on
Unix systems, and will automatically reseed itself from this source
after generating 32 KiB of random data.</p>

<h1 id='cryptographic-security' class='section-header'><a href='#cryptographic-security'>Cryptographic security</a></h1>
<p>An application that requires an entropy source for cryptographic purposes
must use <code>OsRng</code>, which reads randomness from the source that the operating
system provides (e.g. <code>/dev/urandom</code> on Unixes or <code>CryptGenRandom()</code> on
Windows).
The other random number generators provided by this module are not suitable
for such purposes.</p>

<p><em>Note</em>: many Unix systems provide <code>/dev/random</code> as well as <code>/dev/urandom</code>.
This module uses <code>/dev/urandom</code> for the following reasons:</p>

<ul>
<li>  On Linux, <code>/dev/random</code> may block if entropy pool is empty;
<code>/dev/urandom</code> will not block.  This does not mean that <code>/dev/random</code>
provides better output than <code>/dev/urandom</code>; the kernel internally runs a
cryptographically secure pseudorandom number generator (CSPRNG) based on
entropy pool for random number generation, so the &quot;quality&quot; of
<code>/dev/random</code> is not better than <code>/dev/urandom</code> in most cases.  However,
this means that <code>/dev/urandom</code> can yield somewhat predictable randomness
if the entropy pool is very small, such as immediately after first
booting.  Linux 3.17 added the <code>getrandom(2)</code> system call which solves
the issue: it blocks if entropy pool is not initialized yet, but it does
not block once initialized.  <code>OsRng</code> tries to use <code>getrandom(2)</code> if
available, and use <code>/dev/urandom</code> fallback if not.  If an application
does not have <code>getrandom</code> and likely to be run soon after first booting,
or on a system with very few entropy sources, one should consider using
<code>/dev/random</code> via <code>ReadRng</code>.</li>
<li>  On some systems (e.g. FreeBSD, OpenBSD and Mac OS X) there is no
difference between the two sources. (Also note that, on some systems
e.g.  FreeBSD, both <code>/dev/random</code> and <code>/dev/urandom</code> may block once if
the CSPRNG has not seeded yet.)</li>
</ul>

<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>rand</span>::<span class='ident'>Rng</span>;

<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>rng</span> <span class='op'>=</span> <span class='ident'>rand</span>::<span class='ident'>thread_rng</span>();
<span class='kw'>if</span> <span class='ident'>rng</span>.<span class='ident'>gen</span>() { <span class='comment'>// random bool</span>
    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;i32: {}, u32: {}&quot;</span>, <span class='ident'>rng</span>.<span class='ident'>gen</span>::<span class='op'>&lt;</span><span class='ident'>i32</span><span class='op'>&gt;</span>(), <span class='ident'>rng</span>.<span class='ident'>gen</span>::<span class='op'>&lt;</span><span class='ident'>u32</span><span class='op'>&gt;</span>())
}<a class='test-arrow' target='_blank' href=''>Run</a></pre>

<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>tuple</span> <span class='op'>=</span> <span class='ident'>rand</span>::<span class='ident'>random</span>::<span class='op'>&lt;</span>(<span class='ident'>f64</span>, <span class='ident'>char</span>)<span class='op'>&gt;</span>();
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{:?}&quot;</span>, <span class='ident'>tuple</span>)<a class='test-arrow' target='_blank' href=''>Run</a></pre>

<h2 id='monte-carlo-estimation-of-π' class='section-header'><a href='#monte-carlo-estimation-of-π'>Monte Carlo estimation of π</a></h2>
<p>For this example, imagine we have a square with sides of length 2 and a unit
circle, both centered at the origin. Since the area of a unit circle is π,
we have:</p>

<pre><code class="language-text">    (area of unit circle) / (area of square) = π / 4
</code></pre>

<p>So if we sample many points randomly from the square, roughly π / 4 of them
should be inside the circle.</p>

<p>We can use the above fact to estimate the value of π: pick many points in
the square at random, calculate the fraction that fall within the circle,
and multiply this fraction by 4.</p>

<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>rand</span>::<span class='ident'>distributions</span>::{<span class='ident'>IndependentSample</span>, <span class='ident'>Range</span>};

<span class='kw'>fn</span> <span class='ident'>main</span>() {
   <span class='kw'>let</span> <span class='ident'>between</span> <span class='op'>=</span> <span class='ident'>Range</span>::<span class='ident'>new</span>(<span class='op'>-</span><span class='number'>1f64</span>, <span class='number'>1.</span>);
   <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>rng</span> <span class='op'>=</span> <span class='ident'>rand</span>::<span class='ident'>thread_rng</span>();

   <span class='kw'>let</span> <span class='ident'>total</span> <span class='op'>=</span> <span class='number'>1_000_000</span>;
   <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>in_circle</span> <span class='op'>=</span> <span class='number'>0</span>;

   <span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span>..<span class='ident'>total</span> {
       <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>between</span>.<span class='ident'>ind_sample</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>rng</span>);
       <span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>between</span>.<span class='ident'>ind_sample</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>rng</span>);
       <span class='kw'>if</span> <span class='ident'>a</span><span class='op'>*</span><span class='ident'>a</span> <span class='op'>+</span> <span class='ident'>b</span><span class='op'>*</span><span class='ident'>b</span> <span class='op'>&lt;=</span> <span class='number'>1.</span> {
           <span class='ident'>in_circle</span> <span class='op'>+=</span> <span class='number'>1</span>;
       }
   }

   <span class='comment'>// prints something close to 3.14159...</span>
   <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='number'>4.</span> <span class='op'>*</span> (<span class='ident'>in_circle</span> <span class='kw'>as</span> <span class='ident'>f64</span>) <span class='op'>/</span> (<span class='ident'>total</span> <span class='kw'>as</span> <span class='ident'>f64</span>));
}<a class='test-arrow' target='_blank' href=''>Run</a></pre>

<h2 id='monty-hall-problem' class='section-header'><a href='#monty-hall-problem'>Monty Hall Problem</a></h2>
<p>This is a simulation of the <a href="http://en.wikipedia.org/wiki/Monty_Hall_problem">Monty Hall Problem</a>:</p>

<blockquote>
<p>Suppose you&#39;re on a game show, and you&#39;re given the choice of three doors:
Behind one door is a car; behind the others, goats. You pick a door, say
No. 1, and the host, who knows what&#39;s behind the doors, opens another
door, say No. 3, which has a goat. He then says to you, &quot;Do you want to
pick door No. 2?&quot; Is it to your advantage to switch your choice?</p>
</blockquote>

<p>The rather unintuitive answer is that you will have a 2/3 chance of winning
if you switch and a 1/3 chance of winning if you don&#39;t, so it&#39;s better to
switch.</p>

<p>This program will simulate the game show and with large enough simulation
steps it will indeed confirm that it is better to switch.</p>

<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>rand</span>::<span class='ident'>Rng</span>;
<span class='kw'>use</span> <span class='ident'>rand</span>::<span class='ident'>distributions</span>::{<span class='ident'>IndependentSample</span>, <span class='ident'>Range</span>};

<span class='kw'>struct</span> <span class='ident'>SimulationResult</span> {
    <span class='ident'>win</span>: <span class='ident'>bool</span>,
    <span class='ident'>switch</span>: <span class='ident'>bool</span>,
}

<span class='comment'>// Run a single simulation of the Monty Hall problem.</span>
<span class='kw'>fn</span> <span class='ident'>simulate</span><span class='op'>&lt;</span><span class='ident'>R</span>: <span class='ident'>Rng</span><span class='op'>&gt;</span>(<span class='ident'>random_door</span>: <span class='kw-2'>&amp;</span><span class='ident'>Range</span><span class='op'>&lt;</span><span class='ident'>u32</span><span class='op'>&gt;</span>, <span class='ident'>rng</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>R</span>)
                    <span class='op'>-&gt;</span> <span class='ident'>SimulationResult</span> {
    <span class='kw'>let</span> <span class='ident'>car</span> <span class='op'>=</span> <span class='ident'>random_door</span>.<span class='ident'>ind_sample</span>(<span class='ident'>rng</span>);

    <span class='comment'>// This is our initial choice</span>
    <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>choice</span> <span class='op'>=</span> <span class='ident'>random_door</span>.<span class='ident'>ind_sample</span>(<span class='ident'>rng</span>);

    <span class='comment'>// The game host opens a door</span>
    <span class='kw'>let</span> <span class='ident'>open</span> <span class='op'>=</span> <span class='ident'>game_host_open</span>(<span class='ident'>car</span>, <span class='ident'>choice</span>, <span class='ident'>rng</span>);

    <span class='comment'>// Shall we switch?</span>
    <span class='kw'>let</span> <span class='ident'>switch</span> <span class='op'>=</span> <span class='ident'>rng</span>.<span class='ident'>gen</span>();
    <span class='kw'>if</span> <span class='ident'>switch</span> {
        <span class='ident'>choice</span> <span class='op'>=</span> <span class='ident'>switch_door</span>(<span class='ident'>choice</span>, <span class='ident'>open</span>);
    }

    <span class='ident'>SimulationResult</span> { <span class='ident'>win</span>: <span class='ident'>choice</span> <span class='op'>==</span> <span class='ident'>car</span>, <span class='ident'>switch</span>: <span class='ident'>switch</span> }
}

<span class='comment'>// Returns the door the game host opens given our choice and knowledge of</span>
<span class='comment'>// where the car is. The game host will never open the door with the car.</span>
<span class='kw'>fn</span> <span class='ident'>game_host_open</span><span class='op'>&lt;</span><span class='ident'>R</span>: <span class='ident'>Rng</span><span class='op'>&gt;</span>(<span class='ident'>car</span>: <span class='ident'>u32</span>, <span class='ident'>choice</span>: <span class='ident'>u32</span>, <span class='ident'>rng</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>R</span>) <span class='op'>-&gt;</span> <span class='ident'>u32</span> {
    <span class='kw'>let</span> <span class='ident'>choices</span> <span class='op'>=</span> <span class='ident'>free_doors</span>(<span class='kw-2'>&amp;</span>[<span class='ident'>car</span>, <span class='ident'>choice</span>]);
    <span class='ident'>rand</span>::<span class='ident'>sample</span>(<span class='ident'>rng</span>, <span class='ident'>choices</span>.<span class='ident'>into_iter</span>(), <span class='number'>1</span>)[<span class='number'>0</span>]
}

<span class='comment'>// Returns the door we switch to, given our current choice and</span>
<span class='comment'>// the open door. There will only be one valid door.</span>
<span class='kw'>fn</span> <span class='ident'>switch_door</span>(<span class='ident'>choice</span>: <span class='ident'>u32</span>, <span class='ident'>open</span>: <span class='ident'>u32</span>) <span class='op'>-&gt;</span> <span class='ident'>u32</span> {
    <span class='ident'>free_doors</span>(<span class='kw-2'>&amp;</span>[<span class='ident'>choice</span>, <span class='ident'>open</span>])[<span class='number'>0</span>]
}

<span class='kw'>fn</span> <span class='ident'>free_doors</span>(<span class='ident'>blocked</span>: <span class='kw-2'>&amp;</span>[<span class='ident'>u32</span>]) <span class='op'>-&gt;</span> <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>u32</span><span class='op'>&gt;</span> {
    (<span class='number'>0</span>..<span class='number'>3</span>).<span class='ident'>filter</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='op'>!</span><span class='ident'>blocked</span>.<span class='ident'>contains</span>(<span class='ident'>x</span>)).<span class='ident'>collect</span>()
}

<span class='kw'>fn</span> <span class='ident'>main</span>() {
    <span class='comment'>// The estimation will be more accurate with more simulations</span>
    <span class='kw'>let</span> <span class='ident'>num_simulations</span> <span class='op'>=</span> <span class='number'>10000</span>;

    <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>rng</span> <span class='op'>=</span> <span class='ident'>rand</span>::<span class='ident'>thread_rng</span>();
    <span class='kw'>let</span> <span class='ident'>random_door</span> <span class='op'>=</span> <span class='ident'>Range</span>::<span class='ident'>new</span>(<span class='number'>0</span>, <span class='number'>3</span>);

    <span class='kw'>let</span> (<span class='kw-2'>mut</span> <span class='ident'>switch_wins</span>, <span class='kw-2'>mut</span> <span class='ident'>switch_losses</span>) <span class='op'>=</span> (<span class='number'>0</span>, <span class='number'>0</span>);
    <span class='kw'>let</span> (<span class='kw-2'>mut</span> <span class='ident'>keep_wins</span>, <span class='kw-2'>mut</span> <span class='ident'>keep_losses</span>) <span class='op'>=</span> (<span class='number'>0</span>, <span class='number'>0</span>);

    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Running {} simulations...&quot;</span>, <span class='ident'>num_simulations</span>);
    <span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span>..<span class='ident'>num_simulations</span> {
        <span class='kw'>let</span> <span class='ident'>result</span> <span class='op'>=</span> <span class='ident'>simulate</span>(<span class='kw-2'>&amp;</span><span class='ident'>random_door</span>, <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>rng</span>);

        <span class='kw'>match</span> (<span class='ident'>result</span>.<span class='ident'>win</span>, <span class='ident'>result</span>.<span class='ident'>switch</span>) {
            (<span class='bool-val'>true</span>, <span class='bool-val'>true</span>) <span class='op'>=&gt;</span> <span class='ident'>switch_wins</span> <span class='op'>+=</span> <span class='number'>1</span>,
            (<span class='bool-val'>true</span>, <span class='bool-val'>false</span>) <span class='op'>=&gt;</span> <span class='ident'>keep_wins</span> <span class='op'>+=</span> <span class='number'>1</span>,
            (<span class='bool-val'>false</span>, <span class='bool-val'>true</span>) <span class='op'>=&gt;</span> <span class='ident'>switch_losses</span> <span class='op'>+=</span> <span class='number'>1</span>,
            (<span class='bool-val'>false</span>, <span class='bool-val'>false</span>) <span class='op'>=&gt;</span> <span class='ident'>keep_losses</span> <span class='op'>+=</span> <span class='number'>1</span>,
        }
    }

    <span class='kw'>let</span> <span class='ident'>total_switches</span> <span class='op'>=</span> <span class='ident'>switch_wins</span> <span class='op'>+</span> <span class='ident'>switch_losses</span>;
    <span class='kw'>let</span> <span class='ident'>total_keeps</span> <span class='op'>=</span> <span class='ident'>keep_wins</span> <span class='op'>+</span> <span class='ident'>keep_losses</span>;

    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Switched door {} times with {} wins and {} losses&quot;</span>,
             <span class='ident'>total_switches</span>, <span class='ident'>switch_wins</span>, <span class='ident'>switch_losses</span>);

    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Kept our choice {} times with {} wins and {} losses&quot;</span>,
             <span class='ident'>total_keeps</span>, <span class='ident'>keep_wins</span>, <span class='ident'>keep_losses</span>);

    <span class='comment'>// With a large number of simulations, the values should converge to</span>
    <span class='comment'>// 0.667 and 0.333 respectively.</span>
    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Estimated chance to win if we switch: {}&quot;</span>,
             <span class='ident'>switch_wins</span> <span class='kw'>as</span> <span class='ident'>f32</span> <span class='op'>/</span> <span class='ident'>total_switches</span> <span class='kw'>as</span> <span class='ident'>f32</span>);
    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Estimated chance to win if we don&#39;t: {}&quot;</span>,
             <span class='ident'>keep_wins</span> <span class='kw'>as</span> <span class='ident'>f32</span> <span class='op'>/</span> <span class='ident'>total_keeps</span> <span class='kw'>as</span> <span class='ident'>f32</span>);
}<a class='test-arrow' target='_blank' href=''>Run</a></pre>
</div><h2 id='reexports' class='section-header'><a href="#reexports">Reexports</a></h2>
<table><tr><td><code>pub use os::<a class='struct' href='../rand/os/struct.OsRng.html' title='rand::os::OsRng'>OsRng</a>;</code></td></tr><tr><td><code>pub use isaac::{<a class='struct' href='../rand/isaac/struct.IsaacRng.html' title='rand::isaac::IsaacRng'>IsaacRng</a>, <a class='struct' href='../rand/isaac/struct.Isaac64Rng.html' title='rand::isaac::Isaac64Rng'>Isaac64Rng</a>};</code></td></tr><tr><td><code>pub use chacha::<a class='struct' href='../rand/chacha/struct.ChaChaRng.html' title='rand::chacha::ChaChaRng'>ChaChaRng</a>;</code></td></tr></table><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
<table>
                       <tr class=' module-item'>
                           <td><a class='mod' href='chacha/index.html'
                                  title='rand::chacha'>chacha</a></td>
                           <td class='docblock-short'>
                                <p>The ChaCha random number generator.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='mod' href='distributions/index.html'
                                  title='rand::distributions'>distributions</a></td>
                           <td class='docblock-short'>
                                <p>Sampling from random distributions.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='mod' href='isaac/index.html'
                                  title='rand::isaac'>isaac</a></td>
                           <td class='docblock-short'>
                                <p>The ISAAC random number generator.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='mod' href='os/index.html'
                                  title='rand::os'>os</a></td>
                           <td class='docblock-short'>
                                <p>Interfaces to the operating system provided random number
generators.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='mod' href='read/index.html'
                                  title='rand::read'>read</a></td>
                           <td class='docblock-short'>
                                <p>A wrapper around any Read to treat it as an RNG.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='mod' href='reseeding/index.html'
                                  title='rand::reseeding'>reseeding</a></td>
                           <td class='docblock-short'>
                                <p>A wrapper around another RNG that reseeds it after it
generates a certain number of random bytes.</p>
                           </td>
                       </tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.AsciiGenerator.html'
                                  title='rand::AsciiGenerator'>AsciiGenerator</a></td>
                           <td class='docblock-short'>
                                <p>Iterator which will continuously generate random ascii characters.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.Closed01.html'
                                  title='rand::Closed01'>Closed01</a></td>
                           <td class='docblock-short'>
                                <p>A wrapper for generating floating point numbers uniformly in the
closed interval <code>[0,1]</code> (including both endpoints).</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.Generator.html'
                                  title='rand::Generator'>Generator</a></td>
                           <td class='docblock-short'>
                                <p>Iterator which will generate a stream of random items.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.Open01.html'
                                  title='rand::Open01'>Open01</a></td>
                           <td class='docblock-short'>
                                <p>A wrapper for generating floating point numbers uniformly in the
open interval <code>(0,1)</code> (not including either endpoint).</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.StdRng.html'
                                  title='rand::StdRng'>StdRng</a></td>
                           <td class='docblock-short'>
                                <p>The standard RNG. This is designed to be efficient on the current
platform.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.ThreadRng.html'
                                  title='rand::ThreadRng'>ThreadRng</a></td>
                           <td class='docblock-short'>
                                <p>The thread-local RNG.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.XorShiftRng.html'
                                  title='rand::XorShiftRng'>XorShiftRng</a></td>
                           <td class='docblock-short'>
                                <p>An Xorshift[1] random number
generator.</p>
                           </td>
                       </tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table>
                       <tr class=' module-item'>
                           <td><a class='trait' href='trait.Rand.html'
                                  title='rand::Rand'>Rand</a></td>
                           <td class='docblock-short'>
                                <p>A type that can be randomly generated using an <code>Rng</code>.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='trait' href='trait.Rng.html'
                                  title='rand::Rng'>Rng</a></td>
                           <td class='docblock-short'>
                                <p>A random number generator.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='trait' href='trait.SeedableRng.html'
                                  title='rand::SeedableRng'>SeedableRng</a></td>
                           <td class='docblock-short'>
                                <p>A random number generator that can be explicitly seeded to produce
the same stream of randomness multiple times.</p>
                           </td>
                       </tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
                       <tr class=' module-item'>
                           <td><a class='fn' href='fn.random.html'
                                  title='rand::random'>random</a></td>
                           <td class='docblock-short'>
                                <p>Generates a random value using the thread-local random number generator.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='fn' href='fn.sample.html'
                                  title='rand::sample'>sample</a></td>
                           <td class='docblock-short'>
                                <p>Randomly sample up to <code>amount</code> elements from an iterator.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='fn' href='fn.thread_rng.html'
                                  title='rand::thread_rng'>thread_rng</a></td>
                           <td class='docblock-short'>
                                <p>Retrieve the lazily-initialized thread-local random number
generator, seeded by the system. Intended to be used in method
chaining style, e.g. <code>thread_rng().gen::&lt;i32&gt;()</code>.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='fn' href='fn.weak_rng.html'
                                  title='rand::weak_rng'>weak_rng</a></td>
                           <td class='docblock-short'>
                                <p>Create a weak random number generator with a default algorithm and seed.</p>
                           </td>
                       </tr></table></section>
    <section id='search' class="content hidden"></section>

    <section class="footer"></section>

    <aside id="help" class="hidden">
        <div>
            <h1 class="hidden">Help</h1>

            <div class="shortcuts">
                <h2>Keyboard Shortcuts</h2>

                <dl>
                    <dt>?</dt>
                    <dd>Show this help dialog</dd>
                    <dt>S</dt>
                    <dd>Focus the search field</dd>
                    <dt>&larrb;</dt>
                    <dd>Move up in search results</dd>
                    <dt>&rarrb;</dt>
                    <dd>Move down in search results</dd>
                    <dt>&#9166;</dt>
                    <dd>Go to active search result</dd>
                    <dt>+</dt>
                    <dd>Collapse/expand all sections</dd>
                </dl>
            </div>

            <div class="infos">
                <h2>Search Tricks</h2>

                <p>
                    Prefix searches with a type followed by a colon (e.g.
                    <code>fn:</code>) to restrict the search to a given type.
                </p>

                <p>
                    Accepted types are: <code>fn</code>, <code>mod</code>,
                    <code>struct</code>, <code>enum</code>,
                    <code>trait</code>, <code>type</code>, <code>macro</code>,
                    and <code>const</code>.
                </p>

                <p>
                    Search functions by type signature (e.g.
                    <code>vec -> usize</code> or <code>* -> vec</code>)
                </p>
            </div>
        </div>
    </aside>

    

    <script>
        window.rootPath = "../";
        window.currentCrate = "rand";
        window.playgroundUrl = "";
    </script>
    <script src="../jquery.js"></script>
    <script src="../main.js"></script>
    
    <script defer src="../search-index.js"></script>
</body>
</html>