| <!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="The bitvector type."><meta name="keywords" content="rust, rustlang, rust-lang, BitVec"><title>BitVec in bit_vec - 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="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc struct"><!--[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="../bit_vec/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../bit_vec/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">BitVec</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.all">all</a></li><li><a href="#method.and">and</a></li><li><a href="#method.any">any</a></li><li><a href="#method.append">append</a></li><li><a href="#method.blocks">blocks</a></li><li><a href="#method.capacity">capacity</a></li><li><a href="#method.clear">clear</a></li><li><a href="#method.difference">difference</a></li><li><a href="#method.eq_vec">eq_vec</a></li><li><a href="#method.from_bytes">from_bytes</a></li><li><a href="#method.from_elem">from_elem</a></li><li><a href="#method.from_fn">from_fn</a></li><li><a href="#method.get">get</a></li><li><a href="#method.grow">grow</a></li><li><a href="#method.intersect">intersect</a></li><li><a href="#method.is_empty">is_empty</a></li><li><a href="#method.iter">iter</a></li><li><a href="#method.len">len</a></li><li><a href="#method.nand">nand</a></li><li><a href="#method.negate">negate</a></li><li><a href="#method.new">new</a></li><li><a href="#method.none">none</a></li><li><a href="#method.nor">nor</a></li><li><a href="#method.or">or</a></li><li><a href="#method.pop">pop</a></li><li><a href="#method.push">push</a></li><li><a href="#method.reserve">reserve</a></li><li><a href="#method.reserve_exact">reserve_exact</a></li><li><a href="#method.set">set</a></li><li><a href="#method.set_all">set_all</a></li><li><a href="#method.set_len">set_len</a></li><li><a href="#method.shrink_to_fit">shrink_to_fit</a></li><li><a href="#method.split_off">split_off</a></li><li><a href="#method.storage">storage</a></li><li><a href="#method.storage_mut">storage_mut</a></li><li><a href="#method.to_bytes">to_bytes</a></li><li><a href="#method.truncate">truncate</a></li><li><a href="#method.union">union</a></li><li><a href="#method.with_capacity">with_capacity</a></li><li><a href="#method.xnor">xnor</a></li><li><a href="#method.xor">xor</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Clone-for-BitVec%3CB%3E">Clone</a></li><li><a href="#impl-Debug-for-BitVec%3CB%3E">Debug</a></li><li><a href="#impl-Default-for-BitVec%3CB%3E">Default</a></li><li><a href="#impl-Eq-for-BitVec%3CB%3E">Eq</a></li><li><a href="#impl-Extend%3Cbool%3E-for-BitVec%3CB%3E">Extend<bool></a></li><li><a href="#impl-FromIterator%3Cbool%3E-for-BitVec%3CB%3E">FromIterator<bool></a></li><li><a href="#impl-Hash-for-BitVec%3CB%3E">Hash</a></li><li><a href="#impl-Index%3Cusize%3E-for-BitVec%3CB%3E">Index<usize></a></li><li><a href="#impl-IntoIterator-for-%26%27a%20BitVec%3CB%3E">IntoIterator</a></li><li><a href="#impl-IntoIterator-for-BitVec%3CB%3E">IntoIterator</a></li><li><a href="#impl-Ord-for-BitVec%3CB%3E">Ord</a></li><li><a href="#impl-PartialEq%3CBitVec%3CB%3E%3E-for-BitVec%3CB%3E">PartialEq<BitVec<B>></a></li><li><a href="#impl-PartialOrd%3CBitVec%3CB%3E%3E-for-BitVec%3CB%3E">PartialOrd<BitVec<B>></a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-BitVec%3CB%3E">RefUnwindSafe</a></li><li><a href="#impl-Send-for-BitVec%3CB%3E">Send</a></li><li><a href="#impl-Sync-for-BitVec%3CB%3E">Sync</a></li><li><a href="#impl-Unpin-for-BitVec%3CB%3E">Unpin</a></li><li><a href="#impl-UnwindSafe-for-BitVec%3CB%3E">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-BitVec%3CB%3E">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-BitVec%3CB%3E">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-BitVec%3CB%3E">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-BitVec%3CB%3E">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-BitVec%3CB%3E">Into<U></a></li><li><a href="#impl-ToOwned-for-BitVec%3CB%3E">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-BitVec%3CB%3E">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-BitVec%3CB%3E">TryInto<U></a></li></ul></section><h2><a href="index.html">In bit_vec</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><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></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">bit_vec</a>::<wbr><a class="struct" href="#">BitVec</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/bit_vec/lib.rs.html#212-217">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 struct"><code>pub struct BitVec<B = u32> { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The bitvector type.</p> |
| <h2 id="examples"><a href="#examples">Examples</a></h2> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">10</span>, <span class="bool-val">false</span>); |
| |
| <span class="comment">// insert all primes less than 10 |
| </span>bv.set(<span class="number">2</span>, <span class="bool-val">true</span>); |
| bv.set(<span class="number">3</span>, <span class="bool-val">true</span>); |
| bv.set(<span class="number">5</span>, <span class="bool-val">true</span>); |
| bv.set(<span class="number">7</span>, <span class="bool-val">true</span>); |
| <span class="macro">println!</span>(<span class="string">"{:?}"</span>, bv); |
| <span class="macro">println!</span>(<span class="string">"total bits set to true: {}"</span>, bv.iter().filter(|x| <span class="kw-2">*</span>x).count()); |
| |
| <span class="comment">// flip all values in bitvector, producing non-primes less than 10 |
| </span>bv.negate(); |
| <span class="macro">println!</span>(<span class="string">"{:?}"</span>, bv); |
| <span class="macro">println!</span>(<span class="string">"total bits set to true: {}"</span>, bv.iter().filter(|x| <span class="kw-2">*</span>x).count()); |
| |
| <span class="comment">// reset bitvector to empty |
| </span>bv.clear(); |
| <span class="macro">println!</span>(<span class="string">"{:?}"</span>, bv); |
| <span class="macro">println!</span>(<span class="string">"total bits set to true: {}"</span>, bv.iter().filter(|x| <span class="kw-2">*</span>x).count());</code></pre></div> |
| </div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-BitVec%3Cu32%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#258-378">source</a><a href="#impl-BitVec%3Cu32%3E" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><u32></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#269-271">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>() -> Self</h4></section></summary><div class="docblock"><p>Creates an empty <code>BitVec</code>.</p> |
| <h5 id="examples-1"><a href="#examples-1">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::new();</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_elem" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#288-296">source</a><h4 class="code-header">pub fn <a href="#method.from_elem" class="fnname">from_elem</a>(nbits: usize, bit: bool) -> Self</h4></section></summary><div class="docblock"><p>Creates a <code>BitVec</code> that holds <code>nbits</code> elements, setting each element |
| to <code>bit</code>.</p> |
| <h5 id="examples-2"><a href="#examples-2">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">10</span>, <span class="bool-val">false</span>); |
| <span class="macro">assert_eq!</span>(bv.len(), <span class="number">10</span>); |
| <span class="kw">for </span>x <span class="kw">in </span>bv.iter() { |
| <span class="macro">assert_eq!</span>(x, <span class="bool-val">false</span>); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_capacity" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#306-311">source</a><h4 class="code-header">pub fn <a href="#method.with_capacity" class="fnname">with_capacity</a>(nbits: usize) -> Self</h4></section></summary><div class="docblock"><p>Constructs a new, empty <code>BitVec</code> with the specified capacity.</p> |
| <p>The bitvector will be able to hold at least <code>capacity</code> bits without |
| reallocating. If <code>capacity</code> is 0, it will not allocate.</p> |
| <p>It is important to note that this function does not specify the |
| <em>length</em> of the returned bitvector, but only the <em>capacity</em>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_bytes" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#328-355">source</a><h4 class="code-header">pub fn <a href="#method.from_bytes" class="fnname">from_bytes</a>(bytes: &[u8]) -> Self</h4></section></summary><div class="docblock"><p>Transforms a byte-vector into a <code>BitVec</code>. Each byte becomes eight bits, |
| with the most significant bits of each byte coming first. Each |
| bit becomes <code>true</code> if equal to 1 or <code>false</code> if equal to 0.</p> |
| <h5 id="examples-3"><a href="#examples-3">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>bv = BitVec::from_bytes(<span class="kw-2">&</span>[<span class="number">0b10100000</span>, <span class="number">0b00010010</span>]); |
| <span class="macro">assert!</span>(bv.eq_vec(<span class="kw-2">&</span>[<span class="bool-val">true</span>, <span class="bool-val">false</span>, <span class="bool-val">true</span>, <span class="bool-val">false</span>, |
| <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, |
| <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">true</span>, |
| <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">true</span>, <span class="bool-val">false</span>]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_fn" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#369-377">source</a><h4 class="code-header">pub fn <a href="#method.from_fn" class="fnname">from_fn</a><F>(len: usize, f: F) -> Self<span class="where fmt-newline">where<br> F: FnMut(usize) -> bool,</span></h4></section></summary><div class="docblock"><p>Creates a <code>BitVec</code> of the specified length where the value at each index |
| is <code>f(index)</code>.</p> |
| <h5 id="examples-4"><a href="#examples-4">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>bv = BitVec::from_fn(<span class="number">5</span>, |i| { i % <span class="number">2 </span>== <span class="number">0 </span>}); |
| <span class="macro">assert!</span>(bv.eq_vec(<span class="kw-2">&</span>[<span class="bool-val">true</span>, <span class="bool-val">false</span>, <span class="bool-val">true</span>, <span class="bool-val">false</span>, <span class="bool-val">true</span>]));</code></pre></div> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#380-1393">source</a><a href="#impl-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.blocks" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#407-410">source</a><h4 class="code-header">pub fn <a href="#method.blocks" class="fnname">blocks</a>(&self) -> <a class="struct" href="struct.Blocks.html" title="struct bit_vec::Blocks">Blocks</a><'_, B><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.Blocks.html" title="struct bit_vec::Blocks">Blocks</a><'a, B></span><code class="content"><span class="where fmt-newline">impl<'a, B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Iterator for <a class="struct" href="struct.Blocks.html" title="struct bit_vec::Blocks">Blocks</a><'a, B></span><span class="where fmt-newline"> type <a class="associatedtype">Item</a> = B;</span></code></span></span></span></span></h4></section></summary><div class="docblock"><p>Iterator over the underlying blocks of data</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.storage" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#416-418">source</a><h4 class="code-header">pub fn <a href="#method.storage" class="fnname">storage</a>(&self) -> &[B]</h4></section></summary><div class="docblock"><p>Exposes the raw block storage of this BitVec</p> |
| <p>Only really intended for BitSet.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.storage_mut" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#424-426">source</a><h4 class="code-header">pub unsafe fn <a href="#method.storage_mut" class="fnname">storage_mut</a>(&mut self) -> &mut Vec<B></h4></section></summary><div class="docblock"><p>Exposes the raw block storage of this BitVec</p> |
| <p>Can probably cause unsafety. Only really intended for BitSet.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#509-519">source</a><h4 class="code-header">pub fn <a href="#method.get" class="fnname">get</a>(&self, i: usize) -> Option<bool></h4></section></summary><div class="docblock"><p>Retrieves the value at index <code>i</code>, or <code>None</code> if the index is out of bounds.</p> |
| <h5 id="examples-5"><a href="#examples-5">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>bv = BitVec::from_bytes(<span class="kw-2">&</span>[<span class="number">0b01100000</span>]); |
| <span class="macro">assert_eq!</span>(bv.get(<span class="number">0</span>), <span class="prelude-val">Some</span>(<span class="bool-val">false</span>)); |
| <span class="macro">assert_eq!</span>(bv.get(<span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="bool-val">true</span>)); |
| <span class="macro">assert_eq!</span>(bv.get(<span class="number">100</span>), <span class="prelude-val">None</span>); |
| |
| <span class="comment">// Can also use array indexing |
| </span><span class="macro">assert_eq!</span>(bv[<span class="number">1</span>], <span class="bool-val">true</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#537-546">source</a><h4 class="code-header">pub fn <a href="#method.set" class="fnname">set</a>(&mut self, i: usize, x: bool)</h4></section></summary><div class="docblock"><p>Sets the value of a bit at an index <code>i</code>.</p> |
| <h5 id="panics"><a href="#panics">Panics</a></h5> |
| <p>Panics if <code>i</code> is out of bounds.</p> |
| <h5 id="examples-6"><a href="#examples-6">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">5</span>, <span class="bool-val">false</span>); |
| bv.set(<span class="number">3</span>, <span class="bool-val">true</span>); |
| <span class="macro">assert_eq!</span>(bv[<span class="number">3</span>], <span class="bool-val">true</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_all" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#563-567">source</a><h4 class="code-header">pub fn <a href="#method.set_all" class="fnname">set_all</a>(&mut self)</h4></section></summary><div class="docblock"><p>Sets all bits to 1.</p> |
| <h5 id="examples-7"><a href="#examples-7">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>before = <span class="number">0b01100000</span>; |
| <span class="kw">let </span>after = <span class="number">0b11111111</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_bytes(<span class="kw-2">&</span>[before]); |
| bv.set_all(); |
| <span class="macro">assert_eq!</span>(bv, BitVec::from_bytes(<span class="kw-2">&</span>[after]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.negate" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#584-588">source</a><h4 class="code-header">pub fn <a href="#method.negate" class="fnname">negate</a>(&mut self)</h4></section></summary><div class="docblock"><p>Flips all bits.</p> |
| <h5 id="examples-8"><a href="#examples-8">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>before = <span class="number">0b01100000</span>; |
| <span class="kw">let </span>after = <span class="number">0b10011111</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_bytes(<span class="kw-2">&</span>[before]); |
| bv.negate(); |
| <span class="macro">assert_eq!</span>(bv, BitVec::from_bytes(<span class="kw-2">&</span>[after]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.union" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#620-622">source</a><h4 class="code-header">pub fn <a href="#method.union" class="fnname">union</a>(&mut self, other: &Self) -> bool</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.7.0: Please use the ‘or’ function instead</span></div></span></summary><div class="docblock"><p>Calculates the union of two bitvectors. This acts like the bitwise <code>or</code> |
| function.</p> |
| <p>Sets <code>self</code> to the union of <code>self</code> and <code>other</code>. Both bitvectors must be |
| the same length. Returns <code>true</code> if <code>self</code> changed.</p> |
| <h5 id="panics-1"><a href="#panics-1">Panics</a></h5> |
| <p>Panics if the bitvectors are of different lengths.</p> |
| <h5 id="examples-9"><a href="#examples-9">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>a = <span class="number">0b01100100</span>; |
| <span class="kw">let </span>b = <span class="number">0b01011010</span>; |
| <span class="kw">let </span>res = <span class="number">0b01111110</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span>b = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(a.union(<span class="kw-2">&</span>b)); |
| <span class="macro">assert_eq!</span>(a, BitVec::from_bytes(<span class="kw-2">&</span>[res]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.intersect" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#654-656">source</a><h4 class="code-header">pub fn <a href="#method.intersect" class="fnname">intersect</a>(&mut self, other: &Self) -> bool</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.7.0: Please use the ‘and’ function instead</span></div></span></summary><div class="docblock"><p>Calculates the intersection of two bitvectors. This acts like the |
| bitwise <code>and</code> function.</p> |
| <p>Sets <code>self</code> to the intersection of <code>self</code> and <code>other</code>. Both bitvectors |
| must be the same length. Returns <code>true</code> if <code>self</code> changed.</p> |
| <h5 id="panics-2"><a href="#panics-2">Panics</a></h5> |
| <p>Panics if the bitvectors are of different lengths.</p> |
| <h5 id="examples-10"><a href="#examples-10">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>a = <span class="number">0b01100100</span>; |
| <span class="kw">let </span>b = <span class="number">0b01011010</span>; |
| <span class="kw">let </span>res = <span class="number">0b01000000</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span>b = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(a.intersect(<span class="kw-2">&</span>b)); |
| <span class="macro">assert_eq!</span>(a, BitVec::from_bytes(<span class="kw-2">&</span>[res]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.or" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#683-687">source</a><h4 class="code-header">pub fn <a href="#method.or" class="fnname">or</a>(&mut self, other: &Self) -> bool</h4></section></summary><div class="docblock"><p>Calculates the bitwise <code>or</code> of two bitvectors.</p> |
| <p>Sets <code>self</code> to the union of <code>self</code> and <code>other</code>. Both bitvectors must be |
| the same length. Returns <code>true</code> if <code>self</code> changed.</p> |
| <h5 id="panics-3"><a href="#panics-3">Panics</a></h5> |
| <p>Panics if the bitvectors are of different lengths.</p> |
| <h5 id="examples-11"><a href="#examples-11">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>a = <span class="number">0b01100100</span>; |
| <span class="kw">let </span>b = <span class="number">0b01011010</span>; |
| <span class="kw">let </span>res = <span class="number">0b01111110</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span>b = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(a.or(<span class="kw-2">&</span>b)); |
| <span class="macro">assert_eq!</span>(a, BitVec::from_bytes(<span class="kw-2">&</span>[res]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#714-718">source</a><h4 class="code-header">pub fn <a href="#method.and" class="fnname">and</a>(&mut self, other: &Self) -> bool</h4></section></summary><div class="docblock"><p>Calculates the bitwise <code>and</code> of two bitvectors.</p> |
| <p>Sets <code>self</code> to the intersection of <code>self</code> and <code>other</code>. Both bitvectors |
| must be the same length. Returns <code>true</code> if <code>self</code> changed.</p> |
| <h5 id="panics-4"><a href="#panics-4">Panics</a></h5> |
| <p>Panics if the bitvectors are of different lengths.</p> |
| <h5 id="examples-12"><a href="#examples-12">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>a = <span class="number">0b01100100</span>; |
| <span class="kw">let </span>b = <span class="number">0b01011010</span>; |
| <span class="kw">let </span>res = <span class="number">0b01000000</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span>b = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(a.and(<span class="kw-2">&</span>b)); |
| <span class="macro">assert_eq!</span>(a, BitVec::from_bytes(<span class="kw-2">&</span>[res]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.difference" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#753-757">source</a><h4 class="code-header">pub fn <a href="#method.difference" class="fnname">difference</a>(&mut self, other: &Self) -> bool</h4></section></summary><div class="docblock"><p>Calculates the difference between two bitvectors.</p> |
| <p>Sets each element of <code>self</code> to the value of that element minus the |
| element of <code>other</code> at the same index. Both bitvectors must be the same |
| length. Returns <code>true</code> if <code>self</code> changed.</p> |
| <h5 id="panics-5"><a href="#panics-5">Panics</a></h5> |
| <p>Panics if the bitvectors are of different length.</p> |
| <h5 id="examples-13"><a href="#examples-13">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>a = <span class="number">0b01100100</span>; |
| <span class="kw">let </span>b = <span class="number">0b01011010</span>; |
| <span class="kw">let </span>a_b = <span class="number">0b00100100</span>; <span class="comment">// a - b |
| </span><span class="kw">let </span>b_a = <span class="number">0b00011010</span>; <span class="comment">// b - a |
| |
| </span><span class="kw">let </span><span class="kw-2">mut </span>bva = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span>bvb = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(bva.difference(<span class="kw-2">&</span>bvb)); |
| <span class="macro">assert_eq!</span>(bva, BitVec::from_bytes(<span class="kw-2">&</span>[a_b])); |
| |
| <span class="kw">let </span>bva = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span><span class="kw-2">mut </span>bvb = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(bvb.difference(<span class="kw-2">&</span>bva)); |
| <span class="macro">assert_eq!</span>(bvb, BitVec::from_bytes(<span class="kw-2">&</span>[b_a]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.xor" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#784-788">source</a><h4 class="code-header">pub fn <a href="#method.xor" class="fnname">xor</a>(&mut self, other: &Self) -> bool</h4></section></summary><div class="docblock"><p>Calculates the xor of two bitvectors.</p> |
| <p>Sets <code>self</code> to the xor of <code>self</code> and <code>other</code>. Both bitvectors must be |
| the same length. Returns <code>true</code> if <code>self</code> changed.</p> |
| <h5 id="panics-6"><a href="#panics-6">Panics</a></h5> |
| <p>Panics if the bitvectors are of different length.</p> |
| <h5 id="examples-14"><a href="#examples-14">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>a = <span class="number">0b01100110</span>; |
| <span class="kw">let </span>b = <span class="number">0b01010100</span>; |
| <span class="kw">let </span>res = <span class="number">0b00110010</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span>b = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(a.xor(<span class="kw-2">&</span>b)); |
| <span class="macro">assert_eq!</span>(a, BitVec::from_bytes(<span class="kw-2">&</span>[res]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.nand" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#815-822">source</a><h4 class="code-header">pub fn <a href="#method.nand" class="fnname">nand</a>(&mut self, other: &Self) -> bool</h4></section></summary><div class="docblock"><p>Calculates the nand of two bitvectors.</p> |
| <p>Sets <code>self</code> to the nand of <code>self</code> and <code>other</code>. Both bitvectors must be |
| the same length. Returns <code>true</code> if <code>self</code> changed.</p> |
| <h5 id="panics-7"><a href="#panics-7">Panics</a></h5> |
| <p>Panics if the bitvectors are of different length.</p> |
| <h5 id="examples-15"><a href="#examples-15">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>a = <span class="number">0b01100110</span>; |
| <span class="kw">let </span>b = <span class="number">0b01010100</span>; |
| <span class="kw">let </span>res = <span class="number">0b10111011</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span>b = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(a.nand(<span class="kw-2">&</span>b)); |
| <span class="macro">assert_eq!</span>(a, BitVec::from_bytes(<span class="kw-2">&</span>[res]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.nor" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#849-856">source</a><h4 class="code-header">pub fn <a href="#method.nor" class="fnname">nor</a>(&mut self, other: &Self) -> bool</h4></section></summary><div class="docblock"><p>Calculates the nor of two bitvectors.</p> |
| <p>Sets <code>self</code> to the nor of <code>self</code> and <code>other</code>. Both bitvectors must be |
| the same length. Returns <code>true</code> if <code>self</code> changed.</p> |
| <h5 id="panics-8"><a href="#panics-8">Panics</a></h5> |
| <p>Panics if the bitvectors are of different length.</p> |
| <h5 id="examples-16"><a href="#examples-16">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>a = <span class="number">0b01100110</span>; |
| <span class="kw">let </span>b = <span class="number">0b01010100</span>; |
| <span class="kw">let </span>res = <span class="number">0b10001001</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span>b = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(a.nor(<span class="kw-2">&</span>b)); |
| <span class="macro">assert_eq!</span>(a, BitVec::from_bytes(<span class="kw-2">&</span>[res]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.xnor" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#883-890">source</a><h4 class="code-header">pub fn <a href="#method.xnor" class="fnname">xnor</a>(&mut self, other: &Self) -> bool</h4></section></summary><div class="docblock"><p>Calculates the xnor of two bitvectors.</p> |
| <p>Sets <code>self</code> to the xnor of <code>self</code> and <code>other</code>. Both bitvectors must be |
| the same length. Returns <code>true</code> if <code>self</code> changed.</p> |
| <h5 id="panics-9"><a href="#panics-9">Panics</a></h5> |
| <p>Panics if the bitvectors are of different length.</p> |
| <h5 id="examples-17"><a href="#examples-17">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>a = <span class="number">0b01100110</span>; |
| <span class="kw">let </span>b = <span class="number">0b01010100</span>; |
| <span class="kw">let </span>res = <span class="number">0b11001101</span>; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::from_bytes(<span class="kw-2">&</span>[a]); |
| <span class="kw">let </span>b = BitVec::from_bytes(<span class="kw-2">&</span>[b]); |
| |
| <span class="macro">assert!</span>(a.xnor(<span class="kw-2">&</span>b)); |
| <span class="macro">assert_eq!</span>(a, BitVec::from_bytes(<span class="kw-2">&</span>[res]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.all" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#906-916">source</a><h4 class="code-header">pub fn <a href="#method.all" class="fnname">all</a>(&self) -> bool</h4></section></summary><div class="docblock"><p>Returns <code>true</code> if all bits are 1.</p> |
| <h5 id="examples-18"><a href="#examples-18">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">5</span>, <span class="bool-val">true</span>); |
| <span class="macro">assert_eq!</span>(bv.all(), <span class="bool-val">true</span>); |
| |
| bv.set(<span class="number">1</span>, <span class="bool-val">false</span>); |
| <span class="macro">assert_eq!</span>(bv.all(), <span class="bool-val">false</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iter" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#929-932">source</a><h4 class="code-header">pub fn <a href="#method.iter" class="fnname">iter</a>(&self) -> <a class="struct" href="struct.Iter.html" title="struct bit_vec::Iter">Iter</a><'_, B><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.Iter.html" title="struct bit_vec::Iter">Iter</a><'a, B></span><code class="content"><span class="where fmt-newline">impl<'a, B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Iterator for <a class="struct" href="struct.Iter.html" title="struct bit_vec::Iter">Iter</a><'a, B></span><span class="where fmt-newline"> type <a class="associatedtype">Item</a> = bool;</span></code></span></span></span></span></h4></section></summary><div class="docblock"><p>Returns an iterator over the elements of the vector in order.</p> |
| <h5 id="examples-19"><a href="#examples-19">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>bv = BitVec::from_bytes(<span class="kw-2">&</span>[<span class="number">0b01110100</span>, <span class="number">0b10010010</span>]); |
| <span class="macro">assert_eq!</span>(bv.iter().filter(|x| <span class="kw-2">*</span>x).count(), <span class="number">7</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.append" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#951-980">source</a><h4 class="code-header">pub fn <a href="#method.append" class="fnname">append</a>(&mut self, other: &mut Self)</h4></section></summary><div class="docblock"><p>Moves all bits from <code>other</code> into <code>Self</code>, leaving <code>other</code> empty.</p> |
| <h5 id="examples-20"><a href="#examples-20">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::from_bytes(<span class="kw-2">&</span>[<span class="number">0b10000000</span>]); |
| <span class="kw">let </span><span class="kw-2">mut </span>b = BitVec::from_bytes(<span class="kw-2">&</span>[<span class="number">0b01100001</span>]); |
| |
| a.append(<span class="kw-2">&mut </span>b); |
| |
| <span class="macro">assert_eq!</span>(a.len(), <span class="number">16</span>); |
| <span class="macro">assert_eq!</span>(b.len(), <span class="number">0</span>); |
| <span class="macro">assert!</span>(a.eq_vec(<span class="kw-2">&</span>[<span class="bool-val">true</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, |
| <span class="bool-val">false</span>, <span class="bool-val">true</span>, <span class="bool-val">true</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">true</span>]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split_off" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1006-1044">source</a><h4 class="code-header">pub fn <a href="#method.split_off" class="fnname">split_off</a>(&mut self, at: usize) -> Self</h4></section></summary><div class="docblock"><p>Splits the <code>BitVec</code> into two at the given bit, |
| retaining the first half in-place and returning the second one.</p> |
| <h5 id="panics-10"><a href="#panics-10">Panics</a></h5> |
| <p>Panics if <code>at</code> is out of bounds.</p> |
| <h5 id="examples-21"><a href="#examples-21">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| <span class="kw">let </span><span class="kw-2">mut </span>a = BitVec::new(); |
| a.push(<span class="bool-val">true</span>); |
| a.push(<span class="bool-val">false</span>); |
| a.push(<span class="bool-val">false</span>); |
| a.push(<span class="bool-val">true</span>); |
| |
| <span class="kw">let </span>b = a.split_off(<span class="number">2</span>); |
| |
| <span class="macro">assert_eq!</span>(a.len(), <span class="number">2</span>); |
| <span class="macro">assert_eq!</span>(b.len(), <span class="number">2</span>); |
| <span class="macro">assert!</span>(a.eq_vec(<span class="kw-2">&</span>[<span class="bool-val">true</span>, <span class="bool-val">false</span>])); |
| <span class="macro">assert!</span>(b.eq_vec(<span class="kw-2">&</span>[<span class="bool-val">false</span>, <span class="bool-val">true</span>]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.none" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1060-1062">source</a><h4 class="code-header">pub fn <a href="#method.none" class="fnname">none</a>(&self) -> bool</h4></section></summary><div class="docblock"><p>Returns <code>true</code> if all bits are 0.</p> |
| <h5 id="examples-22"><a href="#examples-22">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">10</span>, <span class="bool-val">false</span>); |
| <span class="macro">assert_eq!</span>(bv.none(), <span class="bool-val">true</span>); |
| |
| bv.set(<span class="number">3</span>, <span class="bool-val">true</span>); |
| <span class="macro">assert_eq!</span>(bv.none(), <span class="bool-val">false</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.any" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1078-1080">source</a><h4 class="code-header">pub fn <a href="#method.any" class="fnname">any</a>(&self) -> bool</h4></section></summary><div class="docblock"><p>Returns <code>true</code> if any bit is 1.</p> |
| <h5 id="examples-23"><a href="#examples-23">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">10</span>, <span class="bool-val">false</span>); |
| <span class="macro">assert_eq!</span>(bv.any(), <span class="bool-val">false</span>); |
| |
| bv.set(<span class="number">3</span>, <span class="bool-val">true</span>); |
| <span class="macro">assert_eq!</span>(bv.any(), <span class="bool-val">true</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_bytes" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1103-1127">source</a><h4 class="code-header">pub fn <a href="#method.to_bytes" class="fnname">to_bytes</a>(&self) -> Vec<u8></h4></section></summary><div class="docblock"><p>Organises the bits into bytes, such that the first bit in the |
| <code>BitVec</code> becomes the high-order bit of the first byte. If the |
| size of the <code>BitVec</code> is not a multiple of eight then trailing bits |
| will be filled-in with <code>false</code>.</p> |
| <h5 id="examples-24"><a href="#examples-24">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">3</span>, <span class="bool-val">true</span>); |
| bv.set(<span class="number">1</span>, <span class="bool-val">false</span>); |
| |
| <span class="macro">assert_eq!</span>(bv.to_bytes(), [<span class="number">0b10100000</span>]); |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">9</span>, <span class="bool-val">false</span>); |
| bv.set(<span class="number">2</span>, <span class="bool-val">true</span>); |
| bv.set(<span class="number">8</span>, <span class="bool-val">true</span>); |
| |
| <span class="macro">assert_eq!</span>(bv.to_bytes(), [<span class="number">0b00100000</span>, <span class="number">0b10000000</span>]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq_vec" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1147-1150">source</a><h4 class="code-header">pub fn <a href="#method.eq_vec" class="fnname">eq_vec</a>(&self, v: &[bool]) -> bool</h4></section></summary><div class="docblock"><p>Compares a <code>BitVec</code> to a slice of <code>bool</code>s. |
| Both the <code>BitVec</code> and slice must have the same length.</p> |
| <h5 id="panics-11"><a href="#panics-11">Panics</a></h5> |
| <p>Panics if the <code>BitVec</code> and slice are of different length.</p> |
| <h5 id="examples-25"><a href="#examples-25">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span>bv = BitVec::from_bytes(<span class="kw-2">&</span>[<span class="number">0b10100000</span>]); |
| |
| <span class="macro">assert!</span>(bv.eq_vec(<span class="kw-2">&</span>[<span class="bool-val">true</span>, <span class="bool-val">false</span>, <span class="bool-val">true</span>, <span class="bool-val">false</span>, |
| <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>, <span class="bool-val">false</span>]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.truncate" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1167-1175">source</a><h4 class="code-header">pub fn <a href="#method.truncate" class="fnname">truncate</a>(&mut self, len: usize)</h4></section></summary><div class="docblock"><p>Shortens a <code>BitVec</code>, dropping excess elements.</p> |
| <p>If <code>len</code> is greater than the vector’s current length, this has no |
| effect.</p> |
| <h5 id="examples-26"><a href="#examples-26">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_bytes(<span class="kw-2">&</span>[<span class="number">0b01001011</span>]); |
| bv.truncate(<span class="number">2</span>); |
| <span class="macro">assert!</span>(bv.eq_vec(<span class="kw-2">&</span>[<span class="bool-val">false</span>, <span class="bool-val">true</span>]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reserve" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1195-1201">source</a><h4 class="code-header">pub fn <a href="#method.reserve" class="fnname">reserve</a>(&mut self, additional: usize)</h4></section></summary><div class="docblock"><p>Reserves capacity for at least <code>additional</code> more bits to be inserted in the given |
| <code>BitVec</code>. The collection may reserve more space to avoid frequent reallocations.</p> |
| <h5 id="panics-12"><a href="#panics-12">Panics</a></h5> |
| <p>Panics if the new capacity overflows <code>usize</code>.</p> |
| <h5 id="examples-27"><a href="#examples-27">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">3</span>, <span class="bool-val">false</span>); |
| bv.reserve(<span class="number">10</span>); |
| <span class="macro">assert_eq!</span>(bv.len(), <span class="number">3</span>); |
| <span class="macro">assert!</span>(bv.capacity() >= <span class="number">13</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reserve_exact" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1225-1231">source</a><h4 class="code-header">pub fn <a href="#method.reserve_exact" class="fnname">reserve_exact</a>(&mut self, additional: usize)</h4></section></summary><div class="docblock"><p>Reserves the minimum capacity for exactly <code>additional</code> more bits to be inserted in the |
| given <code>BitVec</code>. Does nothing if the capacity is already sufficient.</p> |
| <p>Note that the allocator may give the collection more space than it requests. Therefore |
| capacity can not be relied upon to be precisely minimal. Prefer <code>reserve</code> if future |
| insertions are expected.</p> |
| <h5 id="panics-13"><a href="#panics-13">Panics</a></h5> |
| <p>Panics if the new capacity overflows <code>usize</code>.</p> |
| <h5 id="examples-28"><a href="#examples-28">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_elem(<span class="number">3</span>, <span class="bool-val">false</span>); |
| bv.reserve(<span class="number">10</span>); |
| <span class="macro">assert_eq!</span>(bv.len(), <span class="number">3</span>); |
| <span class="macro">assert!</span>(bv.capacity() >= <span class="number">13</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.capacity" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1246-1248">source</a><h4 class="code-header">pub fn <a href="#method.capacity" class="fnname">capacity</a>(&self) -> usize</h4></section></summary><div class="docblock"><p>Returns the capacity in bits for this bit vector. Inserting any |
| element less than this amount will not trigger a resizing.</p> |
| <h5 id="examples-29"><a href="#examples-29">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::new(); |
| bv.reserve(<span class="number">10</span>); |
| <span class="macro">assert!</span>(bv.capacity() >= <span class="number">10</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.grow" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1266-1305">source</a><h4 class="code-header">pub fn <a href="#method.grow" class="fnname">grow</a>(&mut self, n: usize, value: bool)</h4></section></summary><div class="docblock"><p>Grows the <code>BitVec</code> in-place, adding <code>n</code> copies of <code>value</code> to the <code>BitVec</code>.</p> |
| <h5 id="panics-14"><a href="#panics-14">Panics</a></h5> |
| <p>Panics if the new len overflows a <code>usize</code>.</p> |
| <h5 id="examples-30"><a href="#examples-30">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_bytes(<span class="kw-2">&</span>[<span class="number">0b01001011</span>]); |
| bv.grow(<span class="number">2</span>, <span class="bool-val">true</span>); |
| <span class="macro">assert_eq!</span>(bv.len(), <span class="number">10</span>); |
| <span class="macro">assert_eq!</span>(bv.to_bytes(), [<span class="number">0b01001011</span>, <span class="number">0b11000000</span>]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.pop" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1320-1337">source</a><h4 class="code-header">pub fn <a href="#method.pop" class="fnname">pop</a>(&mut self) -> Option<bool></h4></section></summary><div class="docblock"><p>Removes the last bit from the BitVec, and returns it. Returns None if the BitVec is empty.</p> |
| <h5 id="examples-31"><a href="#examples-31">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::from_bytes(<span class="kw-2">&</span>[<span class="number">0b01001001</span>]); |
| <span class="macro">assert_eq!</span>(bv.pop(), <span class="prelude-val">Some</span>(<span class="bool-val">true</span>)); |
| <span class="macro">assert_eq!</span>(bv.pop(), <span class="prelude-val">Some</span>(<span class="bool-val">false</span>)); |
| <span class="macro">assert_eq!</span>(bv.len(), <span class="number">6</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.push" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1352-1359">source</a><h4 class="code-header">pub fn <a href="#method.push" class="fnname">push</a>(&mut self, elem: bool)</h4></section></summary><div class="docblock"><p>Pushes a <code>bool</code> onto the end.</p> |
| <h5 id="examples-32"><a href="#examples-32">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bit_vec::BitVec; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>bv = BitVec::new(); |
| bv.push(<span class="bool-val">true</span>); |
| bv.push(<span class="bool-val">false</span>); |
| <span class="macro">assert!</span>(bv.eq_vec(<span class="kw-2">&</span>[<span class="bool-val">true</span>, <span class="bool-val">false</span>]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.len" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1363">source</a><h4 class="code-header">pub fn <a href="#method.len" class="fnname">len</a>(&self) -> usize</h4></section></summary><div class="docblock"><p>Returns the total number of bits in this vector</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_len" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1369-1371">source</a><h4 class="code-header">pub unsafe fn <a href="#method.set_len" class="fnname">set_len</a>(&mut self, len: usize)</h4></section></summary><div class="docblock"><p>Sets the number of bits that this BitVec considers initialized.</p> |
| <p>Almost certainly can cause bad stuff. Only really intended for BitSet.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_empty" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1375">source</a><h4 class="code-header">pub fn <a href="#method.is_empty" class="fnname">is_empty</a>(&self) -> bool</h4></section></summary><div class="docblock"><p>Returns true if there are no bits in this vector</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clear" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1379-1382">source</a><h4 class="code-header">pub fn <a href="#method.clear" class="fnname">clear</a>(&mut self)</h4></section></summary><div class="docblock"><p>Clears all bits in this vector.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.shrink_to_fit" class="method has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1390-1392">source</a><h4 class="code-header">pub fn <a href="#method.shrink_to_fit" class="fnname">shrink_to_fit</a>(&mut self)</h4></section></summary><div class="docblock"><p>Shrinks the capacity of the underlying storage as much as |
| possible.</p> |
| <p>It will drop down as close as possible to the length but the |
| allocator may still inform the underlying storage that there |
| is space for a few more elements/bits.</p> |
| </div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1422-1435">source</a><a href="#impl-Clone-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Clone for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1424-1427">source</a><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone</a>(&self) -> Self</h4></section></summary><div class='docblock'>Returns a copy of the value. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1430-1434">source</a><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone_from</a>(&mut self, source: &Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1465-1473">source</a><a href="#impl-Debug-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Debug for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1466-1472">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&self, fmt: &mut Formatter<'_>) -> Result</h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Default-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1395-1398">source</a><a href="#impl-Default-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Default for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.default" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1397">source</a><a href="#method.default" class="anchor"></a><h4 class="code-header">fn <a class="fnname">default</a>() -> Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Extend%3Cbool%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1409-1420">source</a><a href="#impl-Extend%3Cbool%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Extend<bool> for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.extend" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1411-1419">source</a><a href="#method.extend" class="anchor"></a><h4 class="code-header">fn <a class="fnname">extend</a><I: IntoIterator<Item = bool>>(&mut self, iterable: I)</h4></section></summary><div class='docblock'>Extends a collection with the contents of an iterator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.extend_one" class="method trait-impl has-srclink"><a href="#method.extend_one" class="anchor"></a><h4 class="code-header">fn <a class="fnname">extend_one</a>(&mut self, item: A)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>extend_one</code>)</span></div></span><div class='docblock'>Extends a collection with exactly one element.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.extend_reserve" class="method trait-impl has-srclink"><a href="#method.extend_reserve" class="anchor"></a><h4 class="code-header">fn <a class="fnname">extend_reserve</a>(&mut self, additional: usize)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>extend_one</code>)</span></div></span><div class='docblock'>Reserves capacity in a collection for the given number of additional elements. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-FromIterator%3Cbool%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1400-1407">source</a><a href="#impl-FromIterator%3Cbool%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> FromIterator<bool> for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_iter" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1402-1406">source</a><a href="#method.from_iter" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from_iter</a><I: IntoIterator<Item = bool>>(iter: I) -> Self</h4></section></summary><div class='docblock'>Creates a value from an iterator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hash-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1475-1484">source</a><a href="#impl-Hash-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Hash for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1477-1483">source</a><a href="#method.hash" class="anchor"></a><h4 class="code-header">fn <a class="fnname">hash</a><H: Hasher>(&self, state: &mut H)</h4></section></summary><div class='docblock'>Feeds this value into the given [<code>Hasher</code>]. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.3.0">1.3.0</span><a href="#method.hash_slice" class="anchor"></a><h4 class="code-header">fn <a class="fnname">hash_slice</a><H>(data: &[Self], state: &mut H)<span class="where fmt-newline">where<br> H: Hasher,</span></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given [<code>Hasher</code>]. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Index%3Cusize%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#220-231">source</a><a href="#impl-Index%3Cusize%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Index<usize> for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = bool</h4></section></summary><div class='docblock'>The returned type after indexing.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.index" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#224-230">source</a><a href="#method.index" class="anchor"></a><h4 class="code-header">fn <a class="fnname">index</a>(&self, i: usize) -> &bool</h4></section></summary><div class='docblock'>Performs the indexing (<code>container[index]</code>) operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-IntoIterator-for-%26%27a%20BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1531-1539">source</a><a href="#impl-IntoIterator-for-%26%27a%20BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<'a, B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> IntoIterator for &'a <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Item" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Item</a> = bool</h4></section></summary><div class='docblock'>The type of the elements being iterated over.</div></details><details class="rustdoc-toggle" open><summary><section id="associatedtype.IntoIter" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.IntoIter" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">IntoIter</a> = <a class="struct" href="struct.Iter.html" title="struct bit_vec::Iter">Iter</a><'a, B></h4></section></summary><div class='docblock'>Which kind of iterator are we turning this into?</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into_iter" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1536-1538">source</a><a href="#method.into_iter" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into_iter</a>(self) -> <a class="struct" href="struct.Iter.html" title="struct bit_vec::Iter">Iter</a><'a, B><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.Iter.html" title="struct bit_vec::Iter">Iter</a><'a, B></span><code class="content"><span class="where fmt-newline">impl<'a, B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Iterator for <a class="struct" href="struct.Iter.html" title="struct bit_vec::Iter">Iter</a><'a, B></span><span class="where fmt-newline"> type <a class="associatedtype">Item</a> = bool;</span></code></span></span></span></span></h4></section></summary><div class='docblock'>Creates an iterator from a value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-IntoIterator-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1564-1573">source</a><a href="#impl-IntoIterator-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> IntoIterator for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><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 class="associatedtype">Item</a> = bool</h4></section></summary><div class='docblock'>The type of the elements being iterated over.</div></details><details class="rustdoc-toggle" open><summary><section id="associatedtype.IntoIter-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.IntoIter-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">IntoIter</a> = <a class="struct" href="struct.IntoIter.html" title="struct bit_vec::IntoIter">IntoIter</a><B></h4></section></summary><div class='docblock'>Which kind of iterator are we turning this into?</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into_iter-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1569-1572">source</a><a href="#method.into_iter-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into_iter</a>(self) -> <a class="struct" href="struct.IntoIter.html" title="struct bit_vec::IntoIter">IntoIter</a><B><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.IntoIter.html" title="struct bit_vec::IntoIter">IntoIter</a><B></span><code class="content"><span class="where fmt-newline">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Iterator for <a class="struct" href="struct.IntoIter.html" title="struct bit_vec::IntoIter">IntoIter</a><B></span><span class="where fmt-newline"> type <a class="associatedtype">Item</a> = bool;</span></code></span></span></span></span></h4></section></summary><div class='docblock'>Creates an iterator from a value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Ord-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1444-1463">source</a><a href="#impl-Ord-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Ord for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1446-1462">source</a><a href="#method.cmp" class="anchor"></a><h4 class="code-header">fn <a class="fnname">cmp</a>(&self, other: &Self) -> Ordering</h4></section></summary><div class='docblock'>This method returns an [<code>Ordering</code>] between <code>self</code> and <code>other</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.max" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.21.0">1.21.0</span><a href="#method.max" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">max</a>(self, other: Self) -> Self</h4></section></summary><div class='docblock'>Compares and returns the maximum of two values. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.min" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.21.0">1.21.0</span><a href="#method.min" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">min</a>(self, other: Self) -> Self</h4></section></summary><div class='docblock'>Compares and returns the minimum of two values. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clamp" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.50.0">1.50.0</span><a href="#method.clamp" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">clamp</a>(self, min: Self, max: Self) -> Self<span class="where fmt-newline">where<br> Self: PartialOrd<Self>,</span></h4></section></summary><div class='docblock'>Restrict a value to a certain interval. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBitVec%3CB%3E%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1486-1496">source</a><a href="#impl-PartialEq%3CBitVec%3CB%3E%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> PartialEq<<a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B>> for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1488-1495">source</a><a href="#method.eq" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &Self) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CBitVec%3CB%3E%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1437-1442">source</a><a href="#impl-PartialOrd%3CBitVec%3CB%3E%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> PartialOrd<<a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B>> for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1439-1441">source</a><a href="#method.partial_cmp" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &Self) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><section id="impl-Eq-for-BitVec%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bit_vec/lib.rs.html#1498">source</a><a href="#impl-Eq-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B: <a class="trait" href="trait.BitBlock.html" title="trait bit_vec::BitBlock">BitBlock</a>> Eq for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B></h3></section></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B> RefUnwindSafe for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B><span class="where fmt-newline">where<br> B: RefUnwindSafe,</span></h3></section><section id="impl-Send-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-Send-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B> Send for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B><span class="where fmt-newline">where<br> B: Send,</span></h3></section><section id="impl-Sync-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-Sync-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B> Sync for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B><span class="where fmt-newline">where<br> B: Sync,</span></h3></section><section id="impl-Unpin-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-Unpin-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B> Unpin for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B><span class="where fmt-newline">where<br> B: Unpin,</span></h3></section><section id="impl-UnwindSafe-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-UnwindSafe-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B> UnwindSafe for <a class="struct" href="struct.BitVec.html" title="struct bit_vec::BitVec">BitVec</a><B><span class="where fmt-newline">where<br> B: UnwindSafe,</span></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-Any-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<T> Any for T<span class="where fmt-newline">where<br> T: 'static + ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a class="fnname">type_id</a>(&self) -> TypeId</h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<T> Borrow<T> for T<span class="where fmt-newline">where<br> T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow</a>(&self) -> &T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<T> BorrowMut<T> for T<span class="where fmt-newline">where<br> T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow_mut</a>(&mut self) -> &mut T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<T> From<T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<T, U> Into<U> for T<span class="where fmt-newline">where<br> U: From<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p> |
| <p>That is, this conversion is whatever the implementation of |
| <code>[From]<T> for U</code> chooses to do.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-ToOwned-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<T> ToOwned for T<span class="where fmt-newline">where<br> T: Clone,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><a href="#method.to_owned" class="anchor"></a><h4 class="code-header">fn <a class="fnname">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><a href="#method.clone_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone_into</a>(&self, target: &mut T)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<T, U> TryFrom<U> for T<span class="where fmt-newline">where<br> U: Into<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = Infallible</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_from</a>(value: U) -> Result<T, <T as TryFrom<U>>::Error></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-BitVec%3CB%3E" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-BitVec%3CB%3E" class="anchor"></a><h3 class="code-header">impl<T, U> TryInto<U> for T<span class="where fmt-newline">where<br> U: TryFrom<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = <U as TryFrom<T>>::Error</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_into</a>(self) -> Result<U, <U as TryFrom<T>>::Error></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="bit_vec" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |