]> Untitled Git - bitcoindevkit.org/blob
eb57f38856890c90bbadf40d17cb495c07b81caf
[bitcoindevkit.org] /
1 <!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."><title>SliceRandom in bdk_chain::bitcoin::secp256k1::rand::seq - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-46132b98.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="bdk_chain" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (a4cb3c831 2024-12-17)" data-channel="nightly" data-search-js="search-036cda7a.js" data-settings-js="settings-0f613d39.js" ><script src="../../../../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../../../../bdk_chain/index.html"><img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../../../bdk_chain/index.html"><img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt="logo"></a><h2><a href="../../../../../bdk_chain/index.html">bdk_<wbr>chain</a><span class="version">0.21.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Slice<wbr>Random</a></h2><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Item" title="Item">Item</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.choose" title="choose">choose</a></li><li><a href="#tymethod.choose_multiple" title="choose_multiple">choose_multiple</a></li><li><a href="#tymethod.choose_multiple_weighted" title="choose_multiple_weighted">choose_multiple_weighted</a></li><li><a href="#tymethod.choose_mut" title="choose_mut">choose_mut</a></li><li><a href="#tymethod.choose_weighted" title="choose_weighted">choose_weighted</a></li><li><a href="#tymethod.choose_weighted_mut" title="choose_weighted_mut">choose_weighted_mut</a></li><li><a href="#tymethod.partial_shuffle" title="partial_shuffle">partial_shuffle</a></li><li><a href="#tymethod.shuffle" title="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" title="[T]">[T]</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In bdk_<wbr>chain::<wbr>bitcoin::<wbr>secp256k1::<wbr>rand::<wbr>seq</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../../../index.html">bdk_chain</a>::<wbr><a href="../../../index.html">bitcoin</a>::<wbr><a href="../../index.html">secp256k1</a>::<wbr><a href="../index.html">rand</a>::<wbr><a href="index.html">seq</a></span><h1>Trait <span class="trait">SliceRandom</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#59">Source</a> </span></div><pre class="rust item-decl"><code>pub trait SliceRandom {
2 type <a href="#associatedtype.Item" class="associatedtype">Item</a>;
3
4 // Required methods
5 fn <a href="#tymethod.choose" class="fn">choose</a>&lt;R&gt;(&amp;self, rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt;
6 <span class="where">where R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
7 <span class="item-spacer"></span> fn <a href="#tymethod.choose_mut" class="fn">choose_mut</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt;
8 <span class="where">where R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
9 <span class="item-spacer"></span> fn <a href="#tymethod.choose_multiple" class="fn">choose_multiple</a>&lt;R&gt;(
10 &amp;self,
11 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
12 amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
13 ) -&gt; <a class="struct" href="struct.SliceChooseIter.html" title="struct bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt; <a href="#" class="tooltip" data-notable-ty="SliceChooseIter&lt;&#39;_, Self, Self::Item&gt;">ⓘ</a>
14 <span class="where">where R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
15 <span class="item-spacer"></span> fn <a href="#tymethod.choose_weighted" class="fn">choose_weighted</a>&lt;R, F, B, X&gt;(
16 &amp;self,
17 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
18 weight: F,
19 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/enum.WeightedError.html" title="enum bdk_chain::bitcoin::secp256k1::rand::distributions::WeightedError">WeightedError</a>&gt;
20 <span class="where">where R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
21 F: <a class="trait" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>) -&gt; B,
22 B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,
23 X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'a X</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a></span>;
24 <span class="item-spacer"></span> fn <a href="#tymethod.choose_weighted_mut" class="fn">choose_weighted_mut</a>&lt;R, F, B, X&gt;(
25 &amp;mut self,
26 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
27 weight: F,
28 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/enum.WeightedError.html" title="enum bdk_chain::bitcoin::secp256k1::rand::distributions::WeightedError">WeightedError</a>&gt;
29 <span class="where">where R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
30 F: <a class="trait" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>) -&gt; B,
31 B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,
32 X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'a X</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a></span>;
33 <span class="item-spacer"></span> fn <a href="#tymethod.choose_multiple_weighted" class="fn">choose_multiple_weighted</a>&lt;R, F, X&gt;(
34 &amp;self,
35 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
36 amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
37 weight: F,
38 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.SliceChooseIter.html" title="struct bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt;, <a class="enum" href="../distributions/enum.WeightedError.html" title="enum bdk_chain::bitcoin::secp256k1::rand::distributions::WeightedError">WeightedError</a>&gt;
39 <span class="where">where R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
40 F: <a class="trait" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>) -&gt; X,
41 X: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>&gt;</span>;
42 <span class="item-spacer"></span> fn <a href="#tymethod.shuffle" class="fn">shuffle</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>)
43 <span class="where">where R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
44 <span class="item-spacer"></span> fn <a href="#tymethod.partial_shuffle" class="fn">partial_shuffle</a>&lt;R&gt;(
45 &amp;mut self,
46 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
47 amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
48 ) -&gt; (&amp;mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>], &amp;mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>])
49 <span class="where">where R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;
50 }</code></pre><details class="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>
51 <p>This trait is implemented on all <code>[T]</code> slice types, providing several
52 methods for choosing and shuffling elements. You must <code>use</code> this trait:</p>
53
54 <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand::seq::SliceRandom;
55
56 <span class="kw">let </span><span class="kw-2">mut </span>rng = rand::thread_rng();
57 <span class="kw">let </span><span class="kw-2">mut </span>bytes = <span class="string">"Hello, random!"</span>.to_string().into_bytes();
58 bytes.shuffle(<span class="kw-2">&amp;mut </span>rng);
59 <span class="kw">let </span>str = String::from_utf8(bytes).unwrap();
60 <span class="macro">println!</span>(<span class="string">"{}"</span>, str);</code></pre></div>
61 <p>Example output (non-deterministic):</p>
62 <div class="example-wrap"><pre class="language-none"><code>l,nmroHado !le</code></pre></div></div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Item" class="method"><a class="src rightside" href="https://rust-random.github.io/rand/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>
63 </div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.choose" class="method"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#79-80">Source</a><h4 class="code-header">fn <a href="#tymethod.choose" class="fn">choose</a>&lt;R&gt;(&amp;self, rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt;<div class="where">where
64 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Returns a reference to one random element of the slice, or <code>None</code> if the
65 slice is empty.</p>
66 <p>For slices, complexity is <code>O(1)</code>.</p>
67 <h5 id="example"><a class="doc-anchor" href="#example">§</a>Example</h5>
68 <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand::thread_rng;
69 <span class="kw">use </span>rand::seq::SliceRandom;
70
71 <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>];
72 <span class="kw">let </span><span class="kw-2">mut </span>rng = thread_rng();
73 <span class="macro">println!</span>(<span class="string">"{:?}"</span>, choices.choose(<span class="kw-2">&amp;mut </span>rng));
74 <span class="macro">assert_eq!</span>(choices[..<span class="number">0</span>].choose(<span class="kw-2">&amp;mut </span>rng), <span class="prelude-val">None</span>);</code></pre></div>
75 </div></details><details class="toggle method-toggle" open><summary><section id="tymethod.choose_mut" class="method"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#86-87">Source</a><h4 class="code-header">fn <a href="#tymethod.choose_mut" class="fn">choose_mut</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt;<div class="where">where
76 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Returns a mutable reference to one random element of the slice, or
77 <code>None</code> if the slice is empty.</p>
78 <p>For slices, complexity is <code>O(1)</code>.</p>
79 </div></details><details class="toggle method-toggle" open><summary><section id="tymethod.choose_multiple" class="method"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#115-116">Source</a><h4 class="code-header">fn <a href="#tymethod.choose_multiple" class="fn">choose_multiple</a>&lt;R&gt;(
80 &amp;self,
81 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
82 amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
83 ) -&gt; <a class="struct" href="struct.SliceChooseIter.html" title="struct bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt; <a href="#" class="tooltip" data-notable-ty="SliceChooseIter&lt;&#39;_, Self, Self::Item&gt;">ⓘ</a><div class="where">where
84 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Chooses <code>amount</code> elements from the slice at random, without repetition,
85 and in random order. The returned iterator is appropriate both for
86 collection into a <code>Vec</code> and filling an existing buffer (see example).</p>
87 <p>In case this API is not sufficiently flexible, use <a href="index/fn.sample.html" title="fn bdk_chain::bitcoin::secp256k1::rand::seq::index::sample"><code>index::sample</code></a>.</p>
88 <p>For slices, complexity is the same as <a href="index/fn.sample.html" title="fn bdk_chain::bitcoin::secp256k1::rand::seq::index::sample"><code>index::sample</code></a>.</p>
89 <h5 id="example-1"><a class="doc-anchor" href="#example-1">§</a>Example</h5>
90 <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand::seq::SliceRandom;
91
92 <span class="kw">let </span><span class="kw-2">mut </span>rng = <span class="kw-2">&amp;mut </span>rand::thread_rng();
93 <span class="kw">let </span>sample = <span class="string">"Hello, audience!"</span>.as_bytes();
94
95 <span class="comment">// collect the results into a vector:
96 </span><span class="kw">let </span>v: Vec&lt;u8&gt; = sample.choose_multiple(<span class="kw-2">&amp;mut </span>rng, <span class="number">3</span>).cloned().collect();
97
98 <span class="comment">// store in a buffer:
99 </span><span class="kw">let </span><span class="kw-2">mut </span>buf = [<span class="number">0u8</span>; <span class="number">5</span>];
100 <span class="kw">for </span>(b, slot) <span class="kw">in </span>sample.choose_multiple(<span class="kw-2">&amp;mut </span>rng, buf.len()).zip(buf.iter_mut()) {
101 <span class="kw-2">*</span>slot = <span class="kw-2">*</span>b;
102 }</code></pre></div>
103 </div></details><details class="toggle method-toggle" open><summary><section id="tymethod.choose_weighted" class="method"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#143-154">Source</a><h4 class="code-header">fn <a href="#tymethod.choose_weighted" class="fn">choose_weighted</a>&lt;R, F, B, X&gt;(
104 &amp;self,
105 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
106 weight: F,
107 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/enum.WeightedError.html" title="enum bdk_chain::bitcoin::secp256k1::rand::distributions::WeightedError">WeightedError</a>&gt;<div class="where">where
108 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
109 F: <a class="trait" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>) -&gt; B,
110 B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,
111 X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'a X</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</div></h4></section></summary><div class="docblock"><p>Similar to <a href="trait.SliceRandom.html#tymethod.choose" title="method bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::choose"><code>choose</code></a>, but where the likelihood of each outcome may be
112 specified.</p>
113 <p>The specified function <code>weight</code> maps each item <code>x</code> to a relative
114 likelihood <code>weight(x)</code>. The probability of each item being selected is
115 therefore <code>weight(x) / s</code>, where <code>s</code> is the sum of all <code>weight(x)</code>.</p>
116 <p>For slices of length <code>n</code>, complexity is <code>O(n)</code>.
117 See also <a href="trait.SliceRandom.html#tymethod.choose_weighted_mut" title="method bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::choose_weighted_mut"><code>choose_weighted_mut</code></a>, <a href="../distributions/weighted/index.html" title="mod bdk_chain::bitcoin::secp256k1::rand::distributions::weighted"><code>distributions::weighted</code></a>.</p>
118 <h5 id="example-2"><a class="doc-anchor" href="#example-2">§</a>Example</h5>
119 <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand::prelude::<span class="kw-2">*</span>;
120
121 <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>)];
122 <span class="kw">let </span><span class="kw-2">mut </span>rng = thread_rng();
123 <span class="comment">// 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c'
124 </span><span class="macro">println!</span>(<span class="string">"{:?}"</span>, choices.choose_weighted(<span class="kw-2">&amp;mut </span>rng, |item| item.<span class="number">1</span>).unwrap().<span class="number">0</span>);</code></pre></div>
125 </div></details><details class="toggle method-toggle" open><summary><section id="tymethod.choose_weighted_mut" class="method"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#171-182">Source</a><h4 class="code-header">fn <a href="#tymethod.choose_weighted_mut" class="fn">choose_weighted_mut</a>&lt;R, F, B, X&gt;(
126 &amp;mut self,
127 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
128 weight: F,
129 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/enum.WeightedError.html" title="enum bdk_chain::bitcoin::secp256k1::rand::distributions::WeightedError">WeightedError</a>&gt;<div class="where">where
130 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
131 F: <a class="trait" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>) -&gt; B,
132 B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,
133 X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'a X</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</div></h4></section></summary><div class="docblock"><p>Similar to <a href="trait.SliceRandom.html#tymethod.choose_mut" title="method bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::choose_mut"><code>choose_mut</code></a>, but where the likelihood of each outcome may
134 be specified.</p>
135 <p>The specified function <code>weight</code> maps each item <code>x</code> to a relative
136 likelihood <code>weight(x)</code>. The probability of each item being selected is
137 therefore <code>weight(x) / s</code>, where <code>s</code> is the sum of all <code>weight(x)</code>.</p>
138 <p>For slices of length <code>n</code>, complexity is <code>O(n)</code>.
139 See also <a href="trait.SliceRandom.html#tymethod.choose_weighted" title="method bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::choose_weighted"><code>choose_weighted</code></a>, <a href="../distributions/weighted/index.html" title="mod bdk_chain::bitcoin::secp256k1::rand::distributions::weighted"><code>distributions::weighted</code></a>.</p>
140 </div></details><details class="toggle method-toggle" open><summary><section id="tymethod.choose_multiple_weighted" class="method"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#220-226">Source</a><h4 class="code-header">fn <a href="#tymethod.choose_multiple_weighted" class="fn">choose_multiple_weighted</a>&lt;R, F, X&gt;(
141 &amp;self,
142 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
143 amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
144 weight: F,
145 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.SliceChooseIter.html" title="struct bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, Self, Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt;, <a class="enum" href="../distributions/enum.WeightedError.html" title="enum bdk_chain::bitcoin::secp256k1::rand::distributions::WeightedError">WeightedError</a>&gt;<div class="where">where
146 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
147 F: <a class="trait" href="https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>) -&gt; X,
148 X: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>&gt;,</div></h4></section></summary><div class="docblock"><p>Similar to <a href="trait.SliceRandom.html#tymethod.choose_multiple" title="method bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::choose_multiple"><code>choose_multiple</code></a>, but where the likelihood of each element’s
149 inclusion in the output may be specified. The elements are returned in an
150 arbitrary, unspecified order.</p>
151 <p>The specified function <code>weight</code> maps each item <code>x</code> to a relative
152 likelihood <code>weight(x)</code>. The probability of each item being selected is
153 therefore <code>weight(x) / s</code>, where <code>s</code> is the sum of all <code>weight(x)</code>.</p>
154 <p>If all of the weights are equal, even if they are all zero, each element has
155 an equal likelihood of being selected.</p>
156 <p>The complexity of this method depends on the feature <code>partition_at_index</code>.
157 If the feature is enabled, then for slices of length <code>n</code>, the complexity
158 is <code>O(n)</code> space and <code>O(n)</code> time. Otherwise, the complexity is <code>O(n)</code> space and
159 <code>O(n * log amount)</code> time.</p>
160 <h5 id="example-3"><a class="doc-anchor" href="#example-3">§</a>Example</h5>
161 <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand::prelude::<span class="kw-2">*</span>;
162
163 <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>)];
164 <span class="kw">let </span><span class="kw-2">mut </span>rng = thread_rng();
165 <span class="comment">// First Draw * Second Draw = total odds
166 // -----------------------
167 // (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `['a', 'b']` in some order.
168 // (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `['a', 'c']` in some order.
169 // (25% * 33%) + (25% * 33%) = 16.6% chance that the output is `['b', 'c']` in some order.
170 </span><span class="macro">println!</span>(<span class="string">"{:?}"</span>, choices.choose_multiple_weighted(<span class="kw-2">&amp;mut </span>rng, <span class="number">2</span>, |item| item.<span class="number">1</span>).unwrap().collect::&lt;Vec&lt;<span class="kw">_</span>&gt;&gt;());</code></pre></div>
171 </div></details><details class="toggle method-toggle" open><summary><section id="tymethod.shuffle" class="method"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#244-245">Source</a><h4 class="code-header">fn <a href="#tymethod.shuffle" class="fn">shuffle</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>)<div class="where">where
172 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Shuffle a mutable slice in place.</p>
173 <p>For slices of length <code>n</code>, complexity is <code>O(n)</code>.</p>
174 <h5 id="example-4"><a class="doc-anchor" href="#example-4">§</a>Example</h5>
175 <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand::seq::SliceRandom;
176 <span class="kw">use </span>rand::thread_rng;
177
178 <span class="kw">let </span><span class="kw-2">mut </span>rng = thread_rng();
179 <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>];
180 <span class="macro">println!</span>(<span class="string">"Unshuffled: {:?}"</span>, y);
181 y.shuffle(<span class="kw-2">&amp;mut </span>rng);
182 <span class="macro">println!</span>(<span class="string">"Shuffled: {:?}"</span>, y);</code></pre></div>
183 </div></details><details class="toggle method-toggle" open><summary><section id="tymethod.partial_shuffle" class="method"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#264-267">Source</a><h4 class="code-header">fn <a href="#tymethod.partial_shuffle" class="fn">partial_shuffle</a>&lt;R&gt;(
184 &amp;mut self,
185 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
186 amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
187 ) -&gt; (&amp;mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>], &amp;mut [Self::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>])<div class="where">where
188 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Shuffle a slice in place, but exit early.</p>
189 <p>Returns two mutable slices from the source slice. The first contains
190 <code>amount</code> elements randomly permuted. The second has the remaining
191 elements that are not fully shuffled.</p>
192 <p>This is an efficient method to select <code>amount</code> elements at random from
193 the slice, provided the slice may be mutated.</p>
194 <p>If you only need to choose elements randomly and <code>amount &gt; self.len()/2</code>
195 then you may improve performance by taking
196 <code>amount = values.len() - amount</code> and using only the second slice.</p>
197 <p>If <code>amount</code> is greater than the number of elements in the slice, this
198 will perform a full shuffle.</p>
199 <p>For slices, complexity is <code>O(m)</code> where <code>m = amount</code>.</p>
200 </div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/nightly/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-SliceRandom-for-%5BT%5D" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#492">Source</a><a href="#impl-SliceRandom-for-%5BT%5D" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Item-1" class="associatedtype trait-impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#493">Source</a><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"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#495-496">Source</a><a href="#method.choose" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.choose" class="fn">choose</a>&lt;R&gt;(&amp;self, rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt;<div class="where">where
201 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section><section id="method.choose_mut" class="method trait-impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#504-505">Source</a><a href="#method.choose_mut" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.choose_mut" class="fn">choose_mut</a>&lt;R&gt;(
202 &amp;mut self,
203 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
204 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;mut &lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt;<div class="where">where
205 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section><section id="method.choose_multiple" class="method trait-impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#515-516">Source</a><a href="#method.choose_multiple" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.choose_multiple" class="fn">choose_multiple</a>&lt;R&gt;(
206 &amp;self,
207 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
208 amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
209 ) -&gt; <a class="struct" href="struct.SliceChooseIter.html" title="struct bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a>, &lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt; <a href="#" class="tooltip" data-notable-ty="SliceChooseIter&lt;&#39;_, [T], &lt;[T] as SliceRandom&gt;::Item&gt;">ⓘ</a><div class="where">where
210 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section><section id="method.choose_weighted" class="method trait-impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#526-537">Source</a><a href="#method.choose_weighted" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.choose_weighted" class="fn">choose_weighted</a>&lt;R, F, B, X&gt;(
211 &amp;self,
212 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
213 weight: F,
214 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/enum.WeightedError.html" title="enum bdk_chain::bitcoin::secp256k1::rand::distributions::WeightedError">WeightedError</a>&gt;<div class="where">where
215 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
216 F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>) -&gt; B,
217 B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,
218 X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'a X</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</div></h4></section><section id="method.choose_weighted_mut" class="method trait-impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#545-556">Source</a><a href="#method.choose_weighted_mut" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.choose_weighted_mut" class="fn">choose_weighted_mut</a>&lt;R, F, B, X&gt;(
219 &amp;mut self,
220 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
221 weight: F,
222 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;mut &lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>, <a class="enum" href="../distributions/enum.WeightedError.html" title="enum bdk_chain::bitcoin::secp256k1::rand::distributions::WeightedError">WeightedError</a>&gt;<div class="where">where
223 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
224 F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>) -&gt; B,
225 B: <a class="trait" href="../distributions/uniform/trait.SampleBorrow.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleBorrow">SampleBorrow</a>&lt;X&gt;,
226 X: <a class="trait" href="../distributions/uniform/trait.SampleUniform.html" title="trait bdk_chain::bitcoin::secp256k1::rand::distributions::uniform::SampleUniform">SampleUniform</a> + for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'a X</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</div></h4></section><section id="method.choose_multiple_weighted" class="method trait-impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#564-570">Source</a><a href="#method.choose_multiple_weighted" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.choose_multiple_weighted" class="fn">choose_multiple_weighted</a>&lt;R, F, X&gt;(
227 &amp;self,
228 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
229 amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
230 weight: F,
231 ) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.SliceChooseIter.html" title="struct bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter">SliceChooseIter</a>&lt;'_, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a>, &lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>&gt;, <a class="enum" href="../distributions/enum.WeightedError.html" title="enum bdk_chain::bitcoin::secp256k1::rand::distributions::WeightedError">WeightedError</a>&gt;<div class="where">where
232 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
233 F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>) -&gt; X,
234 X: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>&gt;,</div></h4></section><section id="method.shuffle" class="method trait-impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#586-587">Source</a><a href="#method.shuffle" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.shuffle" class="fn">shuffle</a>&lt;R&gt;(&amp;mut self, rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>)<div class="where">where
235 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section><section id="method.partial_shuffle" class="method trait-impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/seq/mod.rs.html#594-597">Source</a><a href="#method.partial_shuffle" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.partial_shuffle" class="fn">partial_shuffle</a>&lt;R&gt;(
236 &amp;mut self,
237 rng: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut R</a>,
238 amount: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
239 ) -&gt; (&amp;mut [&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>], &amp;mut [&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[T]</a> as <a class="trait" href="trait.SliceRandom.html" title="trait bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom">SliceRandom</a>&gt;::<a class="associatedtype" href="trait.SliceRandom.html#associatedtype.Item" title="type bdk_chain::bitcoin::secp256k1::rand::seq::SliceRandom::Item">Item</a>])<div class="where">where
240 R: <a class="trait" href="../trait.Rng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::Rng">Rng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../../../../trait.impl/rand/seq/trait.SliceRandom.js" data-ignore-extern-crates="std" async></script><script type="text/json" id="notable-traits-data">{"SliceChooseIter<'_, Self, Self::Item>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.SliceChooseIter.html\" title=\"struct bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter\">SliceChooseIter</a>&lt;'a, S, T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;'a, S, T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter\">SliceChooseIter</a>&lt;'a, S, T&gt;<div class=\"where\">where\n S: <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html\" title=\"trait core::ops::index::Index\">Index</a>&lt;<a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.usize.html\">usize</a>, Output = T&gt; + 'a + ?<a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html\" title=\"trait core::marker::Sized\">Sized</a>,\n T: 'a,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.reference.html\">&amp;'a T</a>;</div>","SliceChooseIter<'_, [T], <[T] as SliceRandom>::Item>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.SliceChooseIter.html\" title=\"struct bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter\">SliceChooseIter</a>&lt;'a, S, T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;'a, S, T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/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 bdk_chain::bitcoin::secp256k1::rand::seq::SliceChooseIter\">SliceChooseIter</a>&lt;'a, S, T&gt;<div class=\"where\">where\n S: <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html\" title=\"trait core::ops::index::Index\">Index</a>&lt;<a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.usize.html\">usize</a>, Output = T&gt; + 'a + ?<a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html\" title=\"trait core::marker::Sized\">Sized</a>,\n T: 'a,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.reference.html\">&amp;'a T</a>;</div>"}</script></section></div></main></body></html>