Skip to content

Commit f92b10f

Browse files
committed
deploy: fbe78b7
1 parent 7c537ee commit f92b10f

File tree

6 files changed

+56
-318
lines changed

6 files changed

+56
-318
lines changed

data_structures/bitfield.html

Lines changed: 11 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ <h1 class="menu-title">Rust Cookbook</h1>
161161
<main>
162162
<h1 id="bitfield"><a class="header" href="#bitfield">Bitfield</a></h1>
163163
<h2 id="define-and-operate-on-a-type-represented-as-a-bitfield"><a class="header" href="#define-and-operate-on-a-type-represented-as-a-bitfield">Define and operate on a type represented as a bitfield</a></h2>
164-
<p>[![bitflags-badge]][bitflags] [![cat-no-std-badge]][cat-no-std]</p>
164+
<p><a href="https://docs.rs/bitflags/"><img src="https://badge-cache.kominick.com/crates/v/bitflags.svg?label=bitflags" alt="bitflags-badge" /></a> <a href="https://crates.io/categories/no-std"><img src="https://badge-cache.kominick.com/badge/no_std--x.svg?style=social" alt="cat-no-std-badge" /></a></p>
165165
<p>Creates type safe bitfield type <code>MyFlags</code> with elementary <code>clear</code> operation as well as [<code>Display</code>] trait for it.
166166
Subsequently, shows basic bitwise operations and formatting.</p>
167-
<pre><pre class="playground"><code class="language-rust edition2018">use std::fmt;
167+
<pre><pre class="playground"><code class="language-rust edition2021">use std::fmt;
168168

169169
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
170170
struct MyFlags(u32);
@@ -226,169 +226,23 @@ <h2 id="define-and-operate-on-a-type-represented-as-a-bitfield"><a class="header
226226
fn main() {
227227
let e1 = MyFlags::FLAG_A | MyFlags::FLAG_C;
228228
let e2 = MyFlags::FLAG_B | MyFlags::FLAG_C;
229-
assert_eq!((e1 | e2), MyFlags::FLAG_ABC);
230-
assert_eq!((e1 &amp; e2), MyFlags::FLAG_C);
231-
assert_eq!((e1 - e2), MyFlags::FLAG_A);
232-
assert_eq!(!e2, MyFlags::FLAG_A);
229+
assert_eq!((e1 | e2), MyFlags::FLAG_ABC);
230+
assert_eq!((e1 &amp; e2), MyFlags::FLAG_C);
231+
assert_eq!((e1 - e2), MyFlags::FLAG_A);
232+
assert_eq!(!e2, MyFlags::FLAG_A);
233233

234234
let mut flags = MyFlags::FLAG_ABC;
235235
assert_eq!(format!("{}", flags), "00000000000000000000000000000111");
236236
assert_eq!(format!("{}", flags.clear()), "00000000000000000000000000000000");
237237
assert_eq!(format!("{:?}", MyFlags::FLAG_B), "MyFlags(2)");
238238
assert_eq!(format!("{:?}", MyFlags::FLAG_A | MyFlags::FLAG_B), "MyFlags(3)");
239-
}
240-
241-
&lt;!--
239+
}</code></pre></pre>
240+
<!--
242241
Links, in a few categories. Follow the existing structure.
243242
Keep lines sorted.
244-
--&gt;
245-
246-
&lt;!-- Categories --&gt;
247-
248-
[cat-caching-badge]: https://badge-cache.kominick.com/badge/caching--x.svg?style=social
249-
[cat-caching]: https://crates.io/categories/caching
250-
[cat-command-line-badge]: https://badge-cache.kominick.com/badge/command_line--x.svg?style=social
251-
[cat-command-line]: https://crates.io/categories/command-line-interface
252-
[cat-compression-badge]: https://badge-cache.kominick.com/badge/compression--x.svg?style=social
253-
[cat-compression]: https://crates.io/categories/compression
254-
[cat-concurrency-badge]: https://badge-cache.kominick.com/badge/concurrency--x.svg?style=social
255-
[cat-concurrency]: https://crates.io/categories/concurrency
256-
[cat-config-badge]: https://badge-cache.kominick.com/badge/config--x.svg?style=social
257-
[cat-config]: https://crates.io/categories/config
258-
[cat-cryptography-badge]: https://badge-cache.kominick.com/badge/cryptography--x.svg?style=social
259-
[cat-cryptography]: https://crates.io/categories/cryptography
260-
[cat-database-badge]: https://badge-cache.kominick.com/badge/database--x.svg?style=social
261-
[cat-database]: https://crates.io/categories/database
262-
[cat-date-and-time-badge]: https://badge-cache.kominick.com/badge/date_and_time--x.svg?style=social
263-
[cat-date-and-time]: https://crates.io/categories/date-and-time
264-
[cat-debugging-badge]: https://badge-cache.kominick.com/badge/debugging--x.svg?style=social
265-
[cat-debugging]: https://crates.io/categories/debugging
266-
[cat-development-tools-badge]: https://badge-cache.kominick.com/badge/development_tools--x.svg?style=social
267-
[cat-development-tools]: https://crates.io/categories/development-tools
268-
[cat-encoding-badge]: https://badge-cache.kominick.com/badge/encoding--x.svg?style=social
269-
[cat-encoding]: https://crates.io/categories/encoding
270-
[cat-filesystem-badge]: https://badge-cache.kominick.com/badge/filesystem--x.svg?style=social
271-
[cat-filesystem]: https://crates.io/categories/filesystem
272-
[cat-hardware-support-badge]: https://badge-cache.kominick.com/badge/hardware_support--x.svg?style=social
273-
[cat-hardware-support]: https://crates.io/categories/hardware-support
274-
[cat-net-badge]: https://badge-cache.kominick.com/badge/net--x.svg?style=social
275-
[cat-net]: https://crates.io/categories/network-programming
276-
[cat-no-std-badge]: https://badge-cache.kominick.com/badge/no_std--x.svg?style=social
277-
[cat-no-std]: https://crates.io/categories/no-std
278-
[cat-os-badge]: https://badge-cache.kominick.com/badge/OS--x.svg?style=social
279-
[cat-os]: https://crates.io/categories/os
280-
[cat-rendering-badge]: https://badge-cache.kominick.com/badge/rendering--x.svg?style=social
281-
[cat-rendering]: https://crates.io/categories/rendering
282-
[cat-rust-patterns-badge]: https://badge-cache.kominick.com/badge/rust_patterns--x.svg?style=social
283-
[cat-rust-patterns]: https://crates.io/categories/rust-patterns
284-
[cat-science-badge]: https://badge-cache.kominick.com/badge/science--x.svg?style=social
285-
[cat-science]: https://crates.io/categories/science
286-
[cat-text-processing-badge]: https://badge-cache.kominick.com/badge/text_processing--x.svg?style=social
287-
[cat-text-processing]: https://crates.io/categories/text-processing
288-
[cat-time-badge]: https://badge-cache.kominick.com/badge/time--x.svg?style=social
289-
[cat-time]: https://crates.io/categories/date-and-time
290-
291-
&lt;!-- Crates --&gt;
292-
293-
[ansi_term-badge]: https://badge-cache.kominick.com/crates/v/ansi_term.svg?label=ansi_term
294-
[ansi_term]: https://docs.rs/ansi_term/
295-
[anyhow-badge]: https://badge-cache.kominick.com/crates/v/anyhow.svg?label=anyhow
296-
[anyhow]: https://docs.rs/anyhow/
297-
[base64-badge]: https://badge-cache.kominick.com/crates/v/base64.svg?label=base64
298-
[base64]: https://docs.rs/base64/
299-
[bitflags-badge]: https://badge-cache.kominick.com/crates/v/bitflags.svg?label=bitflags
300-
[bitflags]: https://docs.rs/bitflags/
301-
[byteorder-badge]: https://badge-cache.kominick.com/crates/v/byteorder.svg?label=byteorder
302-
[byteorder]: https://docs.rs/byteorder/
303-
[cc-badge]: https://badge-cache.kominick.com/crates/v/cc.svg?label=cc
304-
[cc]: https://docs.rs/cc
305-
[chrono-badge]: https://badge-cache.kominick.com/crates/v/chrono.svg?label=chrono
306-
[chrono]: https://docs.rs/chrono/
307-
[clap-badge]: https://badge-cache.kominick.com/crates/v/clap.svg?label=clap
308-
[clap]: https://docs.rs/clap/
309-
[crossbeam-badge]: https://badge-cache.kominick.com/crates/v/crossbeam.svg?label=crossbeam
310-
[crossbeam]: https://docs.rs/crossbeam/
311-
[csv-badge]: https://badge-cache.kominick.com/crates/v/csv.svg?label=csv
312-
[csv]: https://docs.rs/csv/
313-
[data-encoding-badge]: https://badge-cache.kominick.com/crates/v/data-encoding.svg?label=data-encoding
314-
[data-encoding]: https://docs.rs/data-encoding/
315-
[env_logger-badge]: https://badge-cache.kominick.com/crates/v/env_logger.svg?label=env_logger
316-
[env_logger]: https://docs.rs/env_logger/
317-
[error-chain-badge]: https://badge-cache.kominick.com/crates/v/error-chain.svg?label=error-chain
318-
[error-chain]: https://docs.rs/error-chain/
319-
[flate2-badge]: https://badge-cache.kominick.com/crates/v/flate2.svg?label=flate2
320-
[flate2]: https://docs.rs/flate2/
321-
[glob-badge]:https://badge-cache.kominick.com/crates/v/glob.svg?label=glob
322-
[glob]: https://docs.rs/glob/
323-
[hyper-badge]: https://badge-cache.kominick.com/crates/v/hyper.svg?label=hyper
324-
[hyper]: https://docs.rs/hyper/
325-
[image-badge]: https://badge-cache.kominick.com/crates/v/image.svg?label=image
326-
[image]: https://docs.rs/image/
327-
[lazy_static-badge]: https://badge-cache.kominick.com/crates/v/lazy_static.svg?label=lazy_static
328-
[lazy_static]: https://docs.rs/lazy_static/
329-
[log-badge]: https://badge-cache.kominick.com/crates/v/log.svg?label=log
330-
[log4rs-badge]: https://badge-cache.kominick.com/crates/v/log4rs.svg?label=log4rs
331-
[log4rs]: https://docs.rs/log4rs/
332-
[log]: https://docs.rs/log/
333-
[memmap-badge]: https://badge-cache.kominick.com/crates/v/memmap.svg?label=memmap
334-
[memmap]: https://docs.rs/memmap/
335-
[mime-badge]: https://badge-cache.kominick.com/crates/v/csv.svg?label=mime
336-
[mime]: https://docs.rs/mime/
337-
[nalgebra-badge]: https://badge-cache.kominick.com/crate/nalgebra.svg?label=nalgebra
338-
[nalgebra]: https://docs.rs/nalgebra
339-
[ndarray-badge]: https://badge-cache.kominick.com/crate/ndarray.svg?label=ndarray
340-
[ndarray]: https://docs.rs/ndarray
341-
[num-badge]: https://badge-cache.kominick.com/crates/v/num.svg?label=num
342-
[num]: https://docs.rs/num/
343-
[num_cpus-badge]: https://badge-cache.kominick.com/crates/v/num_cpus.svg?label=num_cpus
344-
[num_cpus]: https://docs.rs/num_cpus/
345-
[percent-encoding-badge]: https://badge-cache.kominick.com/crates/v/percent-encoding.svg?label=percent-encoding
346-
[postgres-badge]: https://badge-cache.kominick.com/crates/v/postgres.svg?label=postgres
347-
[postgres]: https://docs.rs/postgres/0.15.2/postgres/
348-
[rand-badge]: https://badge-cache.kominick.com/crates/v/rand.svg?label=rand
349-
[rand]: https://docs.rs/rand/
350-
[rand_distr-badge]: https://badge-cache.kominick.com/crates/v/rand_distr.svg?label=rand_distr
351-
[rand_distr]: https://docs.rs/rand_distr/
352-
[rayon-badge]: https://badge-cache.kominick.com/crates/v/rayon.svg?label=rayon
353-
[rayon]: https://docs.rs/rayon/
354-
[regex-badge]: https://badge-cache.kominick.com/crates/v/regex.svg?label=regex
355-
[regex]: https://docs.rs/regex/
356-
[reqwest-badge]: https://badge-cache.kominick.com/crates/v/reqwest.svg?label=reqwest
357-
[reqwest]: https://docs.rs/reqwest/
358-
[ring-badge]: https://badge-cache.kominick.com/crates/v/ring.svg?label=ring
359-
[ring]: https://briansmith.org/rustdoc/ring/
360-
[rusqlite-badge]: https://badge-cache.kominick.com/crates/v/rusqlite.svg?label=rusqlite
361-
[rusqlite]: https://crates.io/crates/rusqlite/
362-
[same_file-badge]: https://badge-cache.kominick.com/crates/v/same_file.svg?label=same_file
363-
[same_file]: https://docs.rs/same-file/
364-
[select-badge]: https://badge-cache.kominick.com/crates/v/select.svg?label=select
365-
[select]: https://docs.rs/select/
366-
[semver-badge]: https://badge-cache.kominick.com/crates/v/semver.svg?label=semver
367-
[semver]: https://docs.rs/semver/
368-
[serde-badge]: https://badge-cache.kominick.com/crates/v/serde.svg?label=serde
369-
[serde-json-badge]: https://badge-cache.kominick.com/crates/v/serde_json.svg?label=serde_json
370-
[serde-json]: https://docs.rs/serde_json/*/serde_json/
371-
[serde]: https://docs.rs/serde/
372-
[std-badge]: https://badge-cache.kominick.com/badge/std-1.29.1-blue.svg
373-
[std]: https://doc.rust-lang.org/std
374-
[syslog-badge]: https://badge-cache.kominick.com/crates/v/syslog.svg?label=syslog
375-
[syslog]: https://docs.rs/syslog/
376-
[tar-badge]: https://badge-cache.kominick.com/crates/v/tar.svg?label=tar
377-
[tar]: https://docs.rs/tar/
378-
[tempfile-badge]: https://badge-cache.kominick.com/crates/v/tempfile.svg?label=tempfile
379-
[tempfile]: https://docs.rs/tempfile/
380-
[thiserror-badge]: https://badge-cache.kominick.com/crates/v/thiserror.svg?label=thiserror
381-
[thiserror]: https://docs.rs/thiserror/
382-
[threadpool-badge]: https://badge-cache.kominick.com/crates/v/threadpool.svg?label=threadpool
383-
[threadpool]: https://docs.rs/threadpool/
384-
[toml-badge]: https://badge-cache.kominick.com/crates/v/toml.svg?label=toml
385-
[toml]: https://docs.rs/toml/
386-
[url-badge]: https://badge-cache.kominick.com/crates/v/url.svg?label=url
387-
[url]: https://docs.rs/url/
388-
[unicode-segmentation-badge]: https://badge-cache.kominick.com/crates/v/unicode-segmentation.svg?label=unicode-segmentation
389-
[unicode-segmentation]: https://docs.rs/unicode-segmentation/
390-
[walkdir-badge]: https://badge-cache.kominick.com/crates/v/walkdir.svg?label=walkdir
391-
[walkdir]: https://docs.rs/walkdir/</code></pre></pre>
243+
-->
244+
<!-- Categories -->
245+
<!-- Crates -->
392246

393247
</main>
394248

hardware/processor.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ <h1 class="menu-title">Rust Cookbook</h1>
162162
<h1 id="processor"><a class="header" href="#processor">Processor</a></h1>
163163
<h2 id="check-number-of-logical-cpu-cores"><a class="header" href="#check-number-of-logical-cpu-cores">Check number of logical cpu cores</a></h2>
164164
<p><a href="https://docs.rs/num_cpus/"><img src="https://badge-cache.kominick.com/crates/v/num_cpus.svg?label=num_cpus" alt="num_cpus-badge" /></a> <a href="https://crates.io/categories/hardware-support"><img src="https://badge-cache.kominick.com/badge/hardware_support--x.svg?style=social" alt="cat-hardware-support-badge" /></a></p>
165-
<p>Shows the number of logical CPU cores in current machine using [<code>num_cpus::get</code>].</p>
165+
<p>Shows the number of logical CPU cores in current machine using <a href="https://docs.rs/num_cpus/latest/num_cpus/fn.get.html"><code>num_cpus::get</code></a>.</p>
166166
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
167167
println!("Number of logical cores is {}", num_cpus::get());
168168
}</code></pre></pre>

mem/global_static.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,21 @@ <h2 id="declare-lazily-evaluated-constant"><a class="header" href="#declare-lazi
187187

188188
show_access("Jim");
189189
}</code></pre></pre>
190+
<h2 id="stdcell"><a class="header" href="#stdcell">Std:cell</a></h2>
191+
<p><a href="https://doc.rust-lang.org/beta/std/cell/struct.OnceCell.html"><code>OnceCell</code></a> is included in the standard library as an alternative.</p>
192+
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">#![allow(unused)]
193+
</span><span class="boring">fn main() {
194+
</span>use std::cell::OnceCell;
195+
196+
let cell = OnceCell::new();
197+
assert!(cell.get().is_none());
198+
199+
let value: &amp;String = cell.get_or_init(|| {
200+
"Hello, World!".to_string()
201+
});
202+
assert_eq!(value, "Hello, World!");
203+
assert!(cell.get().is_some());
204+
<span class="boring">}</span></code></pre></pre>
190205
<!--
191206
Links, in a few categories. Follow the existing structure.
192207
Keep lines sorted.

0 commit comments

Comments
 (0)