Files
greptimedb/common_base/bit_vec/prelude/macro.BitArr.html
2025-12-23 10:07:07 +00:00

30 lines
5.9 KiB
HTML

<!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="Bit-Array Type Definition"><title>BitArr in common_base::bit_vec::prelude - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-e56847b5.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="common_base" data-themes="" data-resource-suffix="" data-rustdoc-version="1.92.0-nightly (fa3155a64 2025-09-30)" data-channel="nightly" data-search-js="search-e256b49e.js" data-stringdex-js="stringdex-828709d0.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-ce535bd0.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">BitArr</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../common_base/index.html">common_<wbr>base</a><span class="version">1.0.0-beta.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">BitArr</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#bit-array-type-definition" title="Bit-Array Type Definition">Bit-Array Type Definition</a><ul><li><a href="#examples" title="Examples">Examples</a></li></ul></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In common_<wbr>base::<wbr>bit_<wbr>vec::<wbr>prelude</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">common_base</a>::<wbr><a href="../index.html">bit_vec</a>::<wbr><a href="index.html">prelude</a></div><h1>Macro <span class="macro">BitArr</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>macro_rules! BitArr {
(for $len:expr, in $store:ty, $order:ty $(,)?) =&gt; { ... };
(for $len:expr, in $store:ty $(,)?) =&gt; { ... };
(for $len:expr) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="bit-array-type-definition"><a class="doc-anchor" href="#bit-array-type-definition">§</a>Bit-Array Type Definition</h2>
<p>Because <code>BitArray&lt;T, O, const BITS: usize&gt;</code> is not expressible in stable Rust,
this macro serves the purpose of creating a type definition that expands to a
suitable <code>BitArray</code>. It creates the correct, rounded-up, <code>BitArray</code> to hold a
requested number of bits in a requested set of ordering/storage parameters.</p>
<p>The macro takes a minimum number of bits to store, and an optional set of
bit-order and bit-store type names, and creates a <code>BitArray</code> that satisfies the
request. As this macro is only usable in type position, it is named with
<code>PascalCase</code> rather than <code>snake_case</code>.</p>
<h3 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h3>
<p>You must provide a bit-count; you may optionally provide a storage type, or a
bit-ordering <em>and</em> a storage type, as subsequent arguments. When elided, the
type parameters are set to the crate defaut type parameters of <code>Lsb0</code> and
<code>usize</code>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bitvec::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>core::cell::Cell;
<span class="kw">let </span>a: <span class="macro">BitArr!</span>(<span class="kw">for </span><span class="number">100</span>) = BitArray::ZERO;
<span class="kw">let </span>b: <span class="macro">BitArr!</span>(<span class="kw">for </span><span class="number">100</span>, <span class="kw">in </span>u32) = BitArray::&lt;<span class="kw">_</span>&gt;::ZERO;
<span class="kw">let </span>c: <span class="macro">BitArr!</span>(<span class="kw">for </span><span class="number">100</span>, <span class="kw">in </span>Cell&lt;u16&gt;, Msb0) = BitArray::&lt;<span class="kw">_</span>, <span class="kw">_</span>&gt;::ZERO;</code></pre></div>
<p>The length expression must be <code>const</code>. It may be a literal, a named <code>const</code>
item, or a <code>const</code> expression, as long as it evaluates to a <code>usize</code>. The type
arguments have no restrictions, as long as they are in-scope at the invocation
site and are implementors of <a href="trait.BitOrder.html" title="trait common_base::bit_vec::prelude::BitOrder"><code>BitOrder</code></a> and <a href="trait.BitStore.html" title="trait common_base::bit_vec::prelude::BitStore"><code>BitStore</code></a>.</p>
</div></details></section></div></main></body></html>