You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
63 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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="Extension trait on slices, providing random mutation and sampling methods."><meta name="keywords" content="rust, rustlang, rust-lang, SliceRandom"><title>SliceRandom in rand::seq - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script>
<noscript><link rel="stylesheet" href="../../noscript.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">&#9776;</button><a class="sidebar-logo" href="../../rand/index.html"><div class="logo-container"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></div>
</a><h2 class="location"></h2>
</nav>
<nav class="sidebar"><a class="sidebar-logo" href="../../rand/index.html"><div class="logo-container">
<img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></div>
</a><h2 class="location"><a href="#">SliceRandom</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Item">Item</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.choose">choose</a></li><li><a href="#tymethod.choose_multiple">choose_multiple</a></li><li><a href="#tymethod.choose_multiple_weighted">choose_multiple_weighted</a></li><li><a href="#tymethod.choose_mut">choose_mut</a></li><li><a href="#tymethod.choose_weighted">choose_weighted</a></li><li><a href="#tymethod.choose_weighted_mut">choose_weighted_mut</a></li><li><a href="#tymethod.partial_shuffle">partial_shuffle</a></li><li><a href="#tymethod.shuffle">shuffle</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul><li><a href="#impl-SliceRandom-for-%5BT%5D">[T]</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In rand::seq</a></h2><div id="sidebar-vars" data-name="SliceRandom" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../rand/index.html">
<img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
<h1 class="fqn"><span class="in-band">Trait <a href="../index.html">rand</a>::<wbr><a href="index.html">seq</a>::<wbr><a class="trait" href="#">SliceRandom</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/rand/seq/mod.rs.html#59-268">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SliceRandom {
type <a href="#associatedtype.Item" class="associatedtype">Item</a>;
fn <a href="#tymethod.choose" class="fnname">choose</a>&lt;R&gt;(&amp;self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.choose_mut" class="fnname">choose_mut</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;mut Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.choose_multiple" class="fnname">choose_multiple</a>&lt;R&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;amount: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'a, S, T&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;'a, S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a>, Output = T&gt; + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a, T:&nbsp;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'a, S, T&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.62.1/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="associatedtype">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;'a </a>T;</span></code></span></span></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.choose_weighted" class="fnname">choose_weighted</a>&lt;R, F, B, X&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;weight: F<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/weighted/enum.WeightedError.html" title="enum rand::distributions::weighted::WeightedError">WeightedError</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -&gt; B,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;'a </a>X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&lt;X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.choose_weighted_mut" class="fnname">choose_weighted_mut</a>&lt;R, F, B, X&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;weight: F<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;mut Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/weighted/enum.WeightedError.html" title="enum rand::distributions::weighted::WeightedError">WeightedError</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -&gt; B,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;'a </a>X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&lt;X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.choose_multiple_weighted" class="fnname">choose_multiple_weighted</a>&lt;R, F, X&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;amount: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;weight: F<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt;, <a class="enum" href="../distributions/weighted/enum.WeightedError.html" title="enum rand::distributions::weighted::WeightedError">WeightedError</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -&gt; X,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.f64.html">f64</a>&gt;</span>;
<span class="item-spacer"></span> fn <a href="#tymethod.shuffle" class="fnname">shuffle</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R)<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.partial_shuffle" class="fnname">partial_shuffle</a>&lt;R&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;amount: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">&amp;mut [</a>Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">]</a>, <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">&amp;mut [</a>Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">]</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.tuple.html">)</a><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Extension trait on slices, providing random mutation and sampling methods.</p>
<p>This trait is implemented on all <code>[T]</code> slice types, providing several
methods for choosing and shuffling elements. You must <code>use</code> this trait:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">rand::seq::SliceRandom</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::thread_rng</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">&quot;Hello, random!&quot;</span>.<span class="ident">to_string</span>().<span class="ident">into_bytes</span>();
<span class="ident">bytes</span>.<span class="ident">shuffle</span>(<span class="kw-2">&amp;mut</span> <span class="ident">rng</span>);
<span class="kw">let</span> <span class="ident">str</span> <span class="op">=</span> <span class="ident">String::from_utf8</span>(<span class="ident">bytes</span>).<span class="ident">unwrap</span>();
<span class="macro">println!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">str</span>);</code></pre></div>
<p>Example output (non-deterministic):</p>
<div class="example-wrap"><pre class="language-none"><code>l,nmroHado !le</code></pre></div></div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Item" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#61">source</a></div><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a></h4></div></summary><div class="docblock"><p>The element type.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.choose" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#79-80">source</a></div><h4 class="code-header">fn <a href="#tymethod.choose" class="fnname">choose</a>&lt;R&gt;(&amp;self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Returns a reference to one random element of the slice, or <code>None</code> if the
slice is empty.</p>
<p>For slices, complexity is <code>O(1)</code>.</p>
<h5 id="example"><a href="#example">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">rand::thread_rng</span>;
<span class="kw">use</span> <span class="ident">rand::seq::SliceRandom</span>;
<span class="kw">let</span> <span class="ident">choices</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>, <span class="number">8</span>, <span class="number">16</span>, <span class="number">32</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rng</span> <span class="op">=</span> <span class="ident">thread_rng</span>();
<span class="macro">println!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">choices</span>.<span class="ident">choose</span>(<span class="kw-2">&amp;mut</span> <span class="ident">rng</span>));
<span class="macro">assert_eq!</span>(<span class="ident">choices</span>[..<span class="number">0</span>].<span class="ident">choose</span>(<span class="kw-2">&amp;mut</span> <span class="ident">rng</span>), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.choose_mut" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#86-87">source</a></div><h4 class="code-header">fn <a href="#tymethod.choose_mut" class="fnname">choose_mut</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;mut Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Returns a mutable reference to one random element of the slice, or
<code>None</code> if the slice is empty.</p>
<p>For slices, complexity is <code>O(1)</code>.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.choose_multiple" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#115-116">source</a></div><h4 class="code-header">fn <a href="#tymethod.choose_multiple" class="fnname">choose_multiple</a>&lt;R&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;amount: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a><br>) -&gt; <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'a, S, T&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;'a, S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a>, Output = T&gt; + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a, T:&nbsp;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'a, S, T&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.62.1/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="associatedtype">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;'a </a>T;</span></code></span></span></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Chooses <code>amount</code> elements from the slice at random, without repetition,
and in random order. The returned iterator is appropriate both for
collection into a <code>Vec</code> and filling an existing buffer (see example).</p>
<p>In case this API is not sufficiently flexible, use <a href="index/fn.sample.html" title="index::sample"><code>index::sample</code></a>.</p>
<p>For slices, complexity is the same as <a href="index/fn.sample.html" title="index::sample"><code>index::sample</code></a>.</p>
<h5 id="example-1"><a href="#example-1">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">rand::seq::SliceRandom</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rng</span> <span class="op">=</span> <span class="kw-2">&amp;mut</span> <span class="ident">rand::thread_rng</span>();
<span class="kw">let</span> <span class="ident">sample</span> <span class="op">=</span> <span class="string">&quot;Hello, audience!&quot;</span>.<span class="ident">as_bytes</span>();
<span class="comment">// collect the results into a vector:</span>
<span class="kw">let</span> <span class="ident">v</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u8</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">sample</span>.<span class="ident">choose_multiple</span>(<span class="kw-2">&amp;mut</span> <span class="ident">rng</span>, <span class="number">3</span>).<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="comment">// store in a buffer:</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0u8</span>; <span class="number">5</span>];
<span class="kw">for</span> (<span class="ident">b</span>, <span class="ident">slot</span>) <span class="kw">in</span> <span class="ident">sample</span>.<span class="ident">choose_multiple</span>(<span class="kw-2">&amp;mut</span> <span class="ident">rng</span>, <span class="ident">buf</span>.<span class="ident">len</span>()).<span class="ident">zip</span>(<span class="ident">buf</span>.<span class="ident">iter_mut</span>()) {
<span class="kw-2">*</span><span class="ident">slot</span> <span class="op">=</span> <span class="kw-2">*</span><span class="ident">b</span>;
}</code></pre></div>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.choose_weighted" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#143-154">source</a></div><h4 class="code-header">fn <a href="#tymethod.choose_weighted" class="fnname">choose_weighted</a>&lt;R, F, B, X&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;weight: F<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/weighted/enum.WeightedError.html" title="enum rand::distributions::weighted::WeightedError">WeightedError</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -&gt; B,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;'a </a>X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&lt;X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Similar to <a href="trait.SliceRandom.html#tymethod.choose"><code>choose</code></a>, but where the likelihood of each outcome may be
specified.</p>
<p>The specified function <code>weight</code> maps each item <code>x</code> to a relative
likelihood <code>weight(x)</code>. The probability of each item being selected is
therefore <code>weight(x) / s</code>, where <code>s</code> is the sum of all <code>weight(x)</code>.</p>
<p>For slices of length <code>n</code>, complexity is <code>O(n)</code>.
See also <a href="trait.SliceRandom.html#tymethod.choose_weighted_mut"><code>choose_weighted_mut</code></a>, <a href="../distributions/weighted/index.html"><code>distributions::weighted</code></a>.</p>
<h5 id="example-2"><a href="#example-2">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">rand::prelude</span>::<span class="kw-2">*</span>;
<span class="kw">let</span> <span class="ident">choices</span> <span class="op">=</span> [(<span class="string">&#39;a&#39;</span>, <span class="number">2</span>), (<span class="string">&#39;b&#39;</span>, <span class="number">1</span>), (<span class="string">&#39;c&#39;</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">thread_rng</span>();
<span class="comment">// 50% chance to print &#39;a&#39;, 25% chance to print &#39;b&#39;, 25% chance to print &#39;c&#39;</span>
<span class="macro">println!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">choices</span>.<span class="ident">choose_weighted</span>(<span class="kw-2">&amp;mut</span> <span class="ident">rng</span>, <span class="op">|</span><span class="ident">item</span><span class="op">|</span> <span class="ident">item</span>.<span class="number">1</span>).<span class="ident">unwrap</span>().<span class="number">0</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.choose_weighted_mut" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#171-182">source</a></div><h4 class="code-header">fn <a href="#tymethod.choose_weighted_mut" class="fnname">choose_weighted_mut</a>&lt;R, F, B, X&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;weight: F<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;mut Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/weighted/enum.WeightedError.html" title="enum rand::distributions::weighted::WeightedError">WeightedError</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -&gt; B,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;'a </a>X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&lt;X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Similar to <a href="trait.SliceRandom.html#tymethod.choose_mut"><code>choose_mut</code></a>, but where the likelihood of each outcome may
be specified.</p>
<p>The specified function <code>weight</code> maps each item <code>x</code> to a relative
likelihood <code>weight(x)</code>. The probability of each item being selected is
therefore <code>weight(x) / s</code>, where <code>s</code> is the sum of all <code>weight(x)</code>.</p>
<p>For slices of length <code>n</code>, complexity is <code>O(n)</code>.
See also <a href="trait.SliceRandom.html#tymethod.choose_weighted"><code>choose_weighted</code></a>, <a href="../distributions/weighted/index.html"><code>distributions::weighted</code></a>.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.choose_multiple_weighted" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#220-226">source</a></div><h4 class="code-header">fn <a href="#tymethod.choose_multiple_weighted" class="fnname">choose_multiple_weighted</a>&lt;R, F, X&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;amount: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;weight: F<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt;, <a class="enum" href="../distributions/weighted/enum.WeightedError.html" title="enum rand::distributions::weighted::WeightedError">WeightedError</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -&gt; X,<br>&nbsp;&nbsp;&nbsp;&nbsp;X: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.f64.html">f64</a>&gt;,&nbsp;</span></h4></div></summary><div class="docblock"><p>Similar to <a href="trait.SliceRandom.html#tymethod.choose_multiple"><code>choose_multiple</code></a>, but where the likelihood of each elements
inclusion in the output may be specified. The elements are returned in an
arbitrary, unspecified order.</p>
<p>The specified function <code>weight</code> maps each item <code>x</code> to a relative
likelihood <code>weight(x)</code>. The probability of each item being selected is
therefore <code>weight(x) / s</code>, where <code>s</code> is the sum of all <code>weight(x)</code>.</p>
<p>If all of the weights are equal, even if they are all zero, each element has
an equal likelihood of being selected.</p>
<p>The complexity of this method depends on the feature <code>partition_at_index</code>.
If the feature is enabled, then for slices of length <code>n</code>, the complexity
is <code>O(n)</code> space and <code>O(n)</code> time. Otherwise, the complexity is <code>O(n)</code> space and
<code>O(n * log amount)</code> time.</p>
<h5 id="example-3"><a href="#example-3">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">rand::prelude</span>::<span class="kw-2">*</span>;
<span class="kw">let</span> <span class="ident">choices</span> <span class="op">=</span> [(<span class="string">&#39;a&#39;</span>, <span class="number">2</span>), (<span class="string">&#39;b&#39;</span>, <span class="number">1</span>), (<span class="string">&#39;c&#39;</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">thread_rng</span>();
<span class="comment">// First Draw * Second Draw = total odds</span>
<span class="comment">// -----------------------</span>
<span class="comment">// (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `[&#39;a&#39;, &#39;b&#39;]` in some order.</span>
<span class="comment">// (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `[&#39;a&#39;, &#39;c&#39;]` in some order.</span>
<span class="comment">// (25% * 33%) + (25% * 33%) = 16.6% chance that the output is `[&#39;b&#39;, &#39;c&#39;]` in some order.</span>
<span class="macro">println!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">choices</span>.<span class="ident">choose_multiple_weighted</span>(<span class="kw-2">&amp;mut</span> <span class="ident">rng</span>, <span class="number">2</span>, <span class="op">|</span><span class="ident">item</span><span class="op">|</span> <span class="ident">item</span>.<span class="number">1</span>).<span class="ident">unwrap</span>().<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span><span class="op">&gt;</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.shuffle" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#244-245">source</a></div><h4 class="code-header">fn <a href="#tymethod.shuffle" class="fnname">shuffle</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Shuffle a mutable slice in place.</p>
<p>For slices of length <code>n</code>, complexity is <code>O(n)</code>.</p>
<h5 id="example-4"><a href="#example-4">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">rand::seq::SliceRandom</span>;
<span class="kw">use</span> <span class="ident">rand::thread_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">thread_rng</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">y</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>];
<span class="macro">println!</span>(<span class="string">&quot;Unshuffled: {:?}&quot;</span>, <span class="ident">y</span>);
<span class="ident">y</span>.<span class="ident">shuffle</span>(<span class="kw-2">&amp;mut</span> <span class="ident">rng</span>);
<span class="macro">println!</span>(<span class="string">&quot;Shuffled: {:?}&quot;</span>, <span class="ident">y</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.partial_shuffle" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#264-267">source</a></div><h4 class="code-header">fn <a href="#tymethod.partial_shuffle" class="fnname">partial_shuffle</a>&lt;R&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;amount: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a><br>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">&amp;mut [</a>Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">]</a>, <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">&amp;mut [</a>Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">]</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.tuple.html">)</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Shuffle a slice in place, but exit early.</p>
<p>Returns two mutable slices from the source slice. The first contains
<code>amount</code> elements randomly permuted. The second has the remaining
elements that are not fully shuffled.</p>
<p>This is an efficient method to select <code>amount</code> elements at random from
the slice, provided the slice may be mutated.</p>
<p>If you only need to choose elements randomly and <code>amount &gt; self.len()/2</code>
then you may improve performance by taking
<code>amount = values.len() - amount</code> and using only the second slice.</p>
<p>If <code>amount</code> is greater than the number of elements in the slice, this
will perform a full shuffle.</p>
<p>For slices, complexity is <code>O(m)</code> where <code>m = amount</code>.</p>
</div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SliceRandom-for-%5BT%5D" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#492-613">source</a></span><a href="#impl-SliceRandom-for-%5BT%5D" class="anchor"></a><h3 class="code-header in-band">impl&lt;T&gt; <a class="trait" href="trait.SliceRandom.html" title="trait rand::seq::SliceRandom">SliceRandom</a> for <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">[</a>T<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">]</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Item-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a> = T</h4></section><section id="method.choose" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#495-502">source</a></span><a href="#method.choose" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose" class="fnname">choose</a>&lt;R&gt;(&amp;self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></section><section id="method.choose_mut" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#504-512">source</a></span><a href="#method.choose_mut" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose_mut" class="fnname">choose_mut</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;mut Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></section><section id="method.choose_multiple" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#515-523">source</a></span><a href="#method.choose_multiple" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose_multiple" class="fnname">choose_multiple</a>&lt;R&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;amount: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a><br>) -&gt; <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'a, S, T&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;'a, S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a>, Output = T&gt; + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a, T:&nbsp;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'a, S, T&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.62.1/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="associatedtype">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;'a </a>T;</span></code></span></span></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></section><section id="method.choose_weighted" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#526-542">source</a></span><a href="#method.choose_weighted" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose_weighted" class="fnname">choose_weighted</a>&lt;R, F, B, X&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;weight: F<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/weighted/enum.WeightedError.html" title="enum rand::distributions::weighted::WeightedError">WeightedError</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -&gt; B,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;'a </a>X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&lt;X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></h4></section><section id="method.choose_weighted_mut" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#545-561">source</a></span><a href="#method.choose_weighted_mut" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose_weighted_mut" class="fnname">choose_weighted_mut</a>&lt;R, F, B, X&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;weight: F<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;mut Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/weighted/enum.WeightedError.html" title="enum rand::distributions::weighted::WeightedError">WeightedError</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -&gt; B,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;'a </a>X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&lt;X&gt; + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></h4></section><section id="method.choose_multiple_weighted" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#564-584">source</a></span><a href="#method.choose_multiple_weighted" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose_multiple_weighted" class="fnname">choose_multiple_weighted</a>&lt;R, F, X&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;amount: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;weight: F<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.62.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>&gt;, <a class="enum" href="../distributions/weighted/enum.WeightedError.html" title="enum rand::distributions::weighted::WeightedError">WeightedError</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -&gt; X,<br>&nbsp;&nbsp;&nbsp;&nbsp;X: <a class="trait" href="https://doc.rust-lang.org/1.62.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.f64.html">f64</a>&gt;,&nbsp;</span></h4></section><section id="method.shuffle" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#586-592">source</a></span><a href="#method.shuffle" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.shuffle" class="fnname">shuffle</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></section><section id="method.partial_shuffle" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/rand/seq/mod.rs.html#594-612">source</a></span><a href="#method.partial_shuffle" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.partial_shuffle" class="fnname">partial_shuffle</a>&lt;R&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;rng: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.reference.html">&amp;mut </a>R, <br>&nbsp;&nbsp;&nbsp;&nbsp;amount: <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.usize.html">usize</a><br>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">&amp;mut [</a>Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">]</a>, <a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">&amp;mut [</a>Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.slice.html">]</a><a class="primitive" href="https://doc.rust-lang.org/1.62.1/std/primitive.tuple.html">)</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.62.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"></div><script type="text/javascript" src="../../implementors/rand/seq/trait.SliceRandom.js" data-ignore-extern-crates="std" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="rand" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.62.1 (e092d0b6b 2022-07-16)" ></div>
</body></html>