diff options
Diffstat (limited to 'rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/seq/trait.SliceRandom.html')
-rw-r--r-- | rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/seq/trait.SliceRandom.html | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/seq/trait.SliceRandom.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/seq/trait.SliceRandom.html new file mode 100644 index 0000000..aeed0b0 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/seq/trait.SliceRandom.html @@ -0,0 +1,127 @@ +<!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" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.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">☰</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></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><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Item">Item</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><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><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-SliceRandom-for-%5BT%5D">[T]</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In rand::seq</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">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></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">−</span>]</a></span></div><div class="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><R>(&self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>><br> <span class="where">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/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><R>(&mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>><br> <span class="where">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/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><R>(<br> &self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> amount: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a><br> ) -> <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a><'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>><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><'a, S, T></span><code class="content"><span class="where fmt-newline">impl<'a, S: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a>, Output = T> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a, T: 'a> <a class="trait" href="https://doc.rust-lang.org/1.66.0/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><'a, S, T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.66.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="associatedtype">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&'a </a>T;</span></code></span></span></span></span><br> <span class="where">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/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><R, F, B, X>(<br> &self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> weight: F<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&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>><br> <span class="where">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -> B,<br> B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a><X>,<br> X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for<'a> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&'a </a>X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a><X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/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><R, F, B, X>(<br> &mut self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> weight: F<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&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>><br> <span class="where">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -> B,<br> B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a><X>,<br> X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for<'a> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&'a </a>X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a><X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/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><R, F, X>(<br> &self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> amount: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a>,<br> weight: F<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a><'_, Self, 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>><br> <span class="where">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -> X,<br> X: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.f64.html">f64</a>></span>; +<span class="item-spacer"></span> fn <a href="#tymethod.shuffle" class="fnname">shuffle</a><R>(&mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R)<br> <span class="where">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/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><R>(<br> &mut self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> amount: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a><br> ) -> (&mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>], &mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>])<br> <span class="where">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/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>rand::seq::SliceRandom; + +<span class="kw">let </span><span class="kw-2">mut </span>rng = rand::thread_rng(); +<span class="kw">let </span><span class="kw-2">mut </span>bytes = <span class="string">"Hello, random!"</span>.to_string().into_bytes(); +bytes.shuffle(<span class="kw-2">&mut </span>rng); +<span class="kw">let </span>str = String::from_utf8(bytes).unwrap(); +<span class="macro">println!</span>(<span class="string">"{}"</span>, str);</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 method-toggle" open><summary><section id="associatedtype.Item" class="method has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#61">source</a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a></h4></section></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 method-toggle" open><summary><section id="tymethod.choose" class="method has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#79-80">source</a><h4 class="code-header">fn <a href="#tymethod.choose" class="fnname">choose</a><R>(&self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></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>rand::thread_rng; +<span class="kw">use </span>rand::seq::SliceRandom; + +<span class="kw">let </span>choices = [<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>rng = thread_rng(); +<span class="macro">println!</span>(<span class="string">"{:?}"</span>, choices.choose(<span class="kw-2">&mut </span>rng)); +<span class="macro">assert_eq!</span>(choices[..<span class="number">0</span>].choose(<span class="kw-2">&mut </span>rng), <span class="prelude-val">None</span>);</code></pre></div> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.choose_mut" class="method has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#86-87">source</a><h4 class="code-header">fn <a href="#tymethod.choose_mut" class="fnname">choose_mut</a><R>(&mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></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 method-toggle" open><summary><section id="tymethod.choose_multiple" class="method has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#115-116">source</a><h4 class="code-header">fn <a href="#tymethod.choose_multiple" class="fnname">choose_multiple</a><R>(<br> &self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> amount: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a><br>) -> <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a><'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>><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><'a, S, T></span><code class="content"><span class="where fmt-newline">impl<'a, S: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a>, Output = T> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a, T: 'a> <a class="trait" href="https://doc.rust-lang.org/1.66.0/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><'a, S, T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.66.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="associatedtype">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&'a </a>T;</span></code></span></span></span></span><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></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>rand::seq::SliceRandom; + +<span class="kw">let </span><span class="kw-2">mut </span>rng = <span class="kw-2">&mut </span>rand::thread_rng(); +<span class="kw">let </span>sample = <span class="string">"Hello, audience!"</span>.as_bytes(); + +<span class="comment">// collect the results into a vector: +</span><span class="kw">let </span>v: Vec<u8> = sample.choose_multiple(<span class="kw-2">&mut </span>rng, <span class="number">3</span>).cloned().collect(); + +<span class="comment">// store in a buffer: +</span><span class="kw">let </span><span class="kw-2">mut </span>buf = [<span class="number">0u8</span>; <span class="number">5</span>]; +<span class="kw">for </span>(b, slot) <span class="kw">in </span>sample.choose_multiple(<span class="kw-2">&mut </span>rng, buf.len()).zip(buf.iter_mut()) { + <span class="kw-2">*</span>slot = <span class="kw-2">*</span>b; +}</code></pre></div> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.choose_weighted" class="method has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#143-154">source</a><h4 class="code-header">fn <a href="#tymethod.choose_weighted" class="fnname">choose_weighted</a><R, F, B, X>(<br> &self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> weight: F<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&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>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -> B,<br> B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a><X>,<br> X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for<'a> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&'a </a>X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a><X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</span></h4></section></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>rand::prelude::<span class="kw-2">*</span>; + +<span class="kw">let </span>choices = [(<span class="string">'a'</span>, <span class="number">2</span>), (<span class="string">'b'</span>, <span class="number">1</span>), (<span class="string">'c'</span>, <span class="number">1</span>)]; +<span class="kw">let </span><span class="kw-2">mut </span>rng = thread_rng(); +<span class="comment">// 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c' +</span><span class="macro">println!</span>(<span class="string">"{:?}"</span>, choices.choose_weighted(<span class="kw-2">&mut </span>rng, |item| item.<span class="number">1</span>).unwrap().<span class="number">0</span>);</code></pre></div> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.choose_weighted_mut" class="method has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#171-182">source</a><h4 class="code-header">fn <a href="#tymethod.choose_weighted_mut" class="fnname">choose_weighted_mut</a><R, F, B, X>(<br> &mut self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> weight: F<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&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>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -> B,<br> B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a><X>,<br> X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for<'a> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&'a </a>X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a><X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</span></h4></section></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 method-toggle" open><summary><section id="tymethod.choose_multiple_weighted" class="method has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#220-226">source</a><h4 class="code-header">fn <a href="#tymethod.choose_multiple_weighted" class="fnname">choose_multiple_weighted</a><R, F, X>(<br> &self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> amount: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a>,<br> weight: F<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a><'_, Self, 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>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -> X,<br> X: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.f64.html">f64</a>>,</span></h4></section></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 element’s +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>rand::prelude::<span class="kw-2">*</span>; + +<span class="kw">let </span>choices = [(<span class="string">'a'</span>, <span class="number">2</span>), (<span class="string">'b'</span>, <span class="number">1</span>), (<span class="string">'c'</span>, <span class="number">1</span>)]; +<span class="kw">let </span><span class="kw-2">mut </span>rng = thread_rng(); +<span class="comment">// First Draw * Second Draw = total odds +// ----------------------- +// (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `['a', 'b']` in some order. +// (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `['a', 'c']` in some order. +// (25% * 33%) + (25% * 33%) = 16.6% chance that the output is `['b', 'c']` in some order. +</span><span class="macro">println!</span>(<span class="string">"{:?}"</span>, choices.choose_multiple_weighted(<span class="kw-2">&mut </span>rng, <span class="number">2</span>, |item| item.<span class="number">1</span>).unwrap().collect::<Vec<<span class="kw">_</span>>>());</code></pre></div> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.shuffle" class="method has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#244-245">source</a><h4 class="code-header">fn <a href="#tymethod.shuffle" class="fnname">shuffle</a><R>(&mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R)<span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></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>rand::seq::SliceRandom; +<span class="kw">use </span>rand::thread_rng; + +<span class="kw">let </span><span class="kw-2">mut </span>rng = thread_rng(); +<span class="kw">let </span><span class="kw-2">mut </span>y = [<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">"Unshuffled: {:?}"</span>, y); +y.shuffle(<span class="kw-2">&mut </span>rng); +<span class="macro">println!</span>(<span class="string">"Shuffled: {:?}"</span>, y);</code></pre></div> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.partial_shuffle" class="method has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#264-267">source</a><h4 class="code-header">fn <a href="#tymethod.partial_shuffle" class="fnname">partial_shuffle</a><R>(<br> &mut self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> amount: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a><br>) -> (&mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>], &mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>])<span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></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 > 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"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#492-613">source</a><a href="#impl-SliceRandom-for-%5BT%5D" class="anchor"></a><h3 class="code-header">impl<T> <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.66.0/std/primitive.slice.html">[T]</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"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#495-502">source</a><a href="#method.choose" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose" class="fnname">choose</a><R>(&self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section><section id="method.choose_mut" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#504-512">source</a><a href="#method.choose_mut" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose_mut" class="fnname">choose_mut</a><R>(&mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section><section id="method.choose_multiple" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#515-523">source</a><a href="#method.choose_multiple" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose_multiple" class="fnname">choose_multiple</a><R>(<br> &self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> amount: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a><br>) -> <a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a><'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>><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><'a, S, T></span><code class="content"><span class="where fmt-newline">impl<'a, S: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a>, Output = T> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a, T: 'a> <a class="trait" href="https://doc.rust-lang.org/1.66.0/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><'a, S, T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.66.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="associatedtype">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&'a </a>T;</span></code></span></span></span></span><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section><section id="method.choose_weighted" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#526-542">source</a><a href="#method.choose_weighted" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.choose_weighted" class="fnname">choose_weighted</a><R, F, B, X>(<br> &self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> weight: F<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&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>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -> B,<br> B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a><X>,<br> X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for<'a> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&'a </a>X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a><X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</span></h4></section><section id="method.choose_weighted_mut" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#545-561">source</a><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><R, F, B, X>(<br> &mut self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> weight: F<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&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>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -> B,<br> B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait rand::distributions::uniform::SampleBorrow">SampleBorrow</a><X>,<br> X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait rand::distributions::uniform::SampleUniform">SampleUniform</a> + for<'a> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&'a </a>X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a><X> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</span></h4></section><section id="method.choose_multiple_weighted" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#564-584">source</a><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><R, F, X>(<br> &self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> amount: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a>,<br> weight: F<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.SliceChooseIter.html" title="struct rand::seq::SliceChooseIter">SliceChooseIter</a><'_, Self, 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>><span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>) -> X,<br> X: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.f64.html">f64</a>>,</span></h4></section><section id="method.shuffle" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#586-592">source</a><a href="#method.shuffle" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.shuffle" class="fnname">shuffle</a><R>(&mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R)<span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section><section id="method.partial_shuffle" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rand/seq/mod.rs.html#594-612">source</a><a href="#method.partial_shuffle" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.partial_shuffle" class="fnname">partial_shuffle</a><R>(<br> &mut self,<br> rng: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>R,<br> amount: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a><br>) -> (&mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>], &mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type rand::seq::SliceRandom::Item">Item</a>])<span class="where fmt-newline">where<br> R: <a class="trait" href="../trait.Rng.html" title="trait rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"></div><script 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.66.0 (69f9c33d7 2022-12-12) (Arch Linux rust 1:1.66.0-1)" ></div></body></html>
\ No newline at end of file |