Auto Generated Documentation
This commit is contained in:
+11
-12
@@ -1,10 +1,10 @@
|
||||
<!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="Overview"><meta name="keywords" content="rust, rustlang, rust-lang, once_cell"><title>once_cell - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<!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="API documentation for the Rust `once_cell` crate."><meta name="keywords" content="rust, rustlang, rust-lang, once_cell"><title>once_cell - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../once_cell/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate once_cell</p><div class="block version"><p>Version 1.7.2</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all once_cell's items</p></a><div class="block items"><ul><li><a href="#modules">Modules</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="once_cell" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">once_cell</a></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/once_cell/lib.rs.html#1-1080" title="goto source code">[src]</a></span></h1><div class="docblock"><h1 id="overview" class="section-header"><a href="#overview">Overview</a></h1>
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../once_cell/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate once_cell</p><div class="block version"><p>Version 1.7.2</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all once_cell's items</p></a><div class="block items"><ul><li><a href="#modules">Modules</a></li></ul></div><p class="location"></p><script>window.sidebarCurrent = {name: "once_cell", ty: "mod", relpath: "../"};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/once_cell/lib.rs.html#1-1080" title="goto source code">[src]</a></span><span class="in-band">Crate <a class="mod" href="">once_cell</a></span></h1><div class="docblock"><h1 id="overview" class="section-header"><a href="#overview">Overview</a></h1>
|
||||
<p><code>once_cell</code> provides two new cell-like types, <a href="unsync/struct.OnceCell.html"><code>unsync::OnceCell</code></a> and <a href="sync/struct.OnceCell.html"><code>sync::OnceCell</code></a>. A <code>OnceCell</code>
|
||||
might store arbitrary non-<code>Copy</code> types, can be assigned to at most once and provides direct access
|
||||
to the stored contents. The core API looks <em>roughly</em> like this (and there’s much more inside, read on!):</p>
|
||||
to the stored contents. The core API looks <em>roughly</em> like this (and there's much more inside, read on!):</p>
|
||||
|
||||
<div class='information'><div class='tooltip ignore'>ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore">
|
||||
<span class="kw">impl</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> <span class="ident">OnceCell</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> {
|
||||
@@ -124,7 +124,7 @@ For example, this is a <code>regex!</code> macro which takes a string literal an
|
||||
<span class="ident">RE</span>.<span class="ident">get_or_init</span>(<span class="op">|</span><span class="op">|</span> <span class="ident">regex</span>::<span class="ident">Regex</span>::<span class="ident">new</span>(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">re</span>).<span class="ident">unwrap</span>())
|
||||
}};
|
||||
}</pre></div>
|
||||
<p>This macro can be useful to avoid the “compile regex on every loop iteration” problem.</p>
|
||||
<p>This macro can be useful to avoid the "compile regex on every loop iteration" problem.</p>
|
||||
<p>Another pattern would be a <code>LateInit</code> type for delayed initialization:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
@@ -181,7 +181,7 @@ For example, this is a <code>regex!</code> macro which takes a string literal an
|
||||
itself. However, because the assignment can happen only once, such cases should be more rare than
|
||||
equivalents with <code>RefCell</code> and <code>Mutex</code>.</p>
|
||||
<h1 id="minimum-supported-rustc-version" class="section-header"><a href="#minimum-supported-rustc-version">Minimum Supported <code>rustc</code> Version</a></h1>
|
||||
<p>This crate’s minimum supported <code>rustc</code> version is <code>1.36.0</code>.</p>
|
||||
<p>This crate's minimum supported <code>rustc</code> version is <code>1.36.0</code>.</p>
|
||||
<p>If only the <code>std</code> feature is enabled, MSRV will be updated conservatively.
|
||||
When using other features, like <code>parking_lot</code>, MSRV might be updated more frequently, up to the latest stable.
|
||||
In both cases, increasing MSRV is <em>not</em> considered a semver-breaking change.</p>
|
||||
@@ -204,8 +204,8 @@ and should be preferred.</p>
|
||||
<p><code>lazy_static</code> has received significantly more real world testing, but <code>once_cell</code> is also a widely
|
||||
used crate.</p>
|
||||
<p><strong>Should I use the sync or unsync flavor?</strong></p>
|
||||
<p>Because Rust compiler checks thread safety for you, it’s impossible to accidentally use <code>unsync</code> where
|
||||
<code>sync</code> is required. So, use <code>unsync</code> in single-threaded code and <code>sync</code> in multi-threaded. It’s easy
|
||||
<p>Because Rust compiler checks thread safety for you, it's impossible to accidentally use <code>unsync</code> where
|
||||
<code>sync</code> is required. So, use <code>unsync</code> in single-threaded code and <code>sync</code> in multi-threaded. It's easy
|
||||
to switch between the two if code becomes multi-threaded later.</p>
|
||||
<p>At the moment, <code>unsync</code> has an additional benefit that reentrant initialization causes a panic, which
|
||||
might be easier to debug than a deadlock.</p>
|
||||
@@ -217,9 +217,8 @@ might be easier to debug than a deadlock.</p>
|
||||
<li><a href="https://crates.io/crates/mitochondria">mitochondria</a></li>
|
||||
<li><a href="https://crates.io/crates/lazy_static">lazy_static</a></li>
|
||||
</ul>
|
||||
<p>Most of this crate’s functionality is available in <code>std</code> in nightly Rust.
|
||||
<p>Most of this crate's functionality is available in <code>std</code> in nightly Rust.
|
||||
See the <a href="https://github.com/rust-lang/rust/issues/74465">tracking issue</a>.</p>
|
||||
</div><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
|
||||
<table><tr class="module-item"><td><a class="mod" href="race/index.html" title="once_cell::race mod">race</a></td><td class="docblock-short"><p>“First one wins” flavor of <code>OnceCell</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="mod" href="sync/index.html" title="once_cell::sync mod">sync</a></td><td class="docblock-short"></td></tr><tr class="module-item"><td><a class="mod" href="unsync/index.html" title="once_cell::unsync mod">unsync</a></td><td class="docblock-short"></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="once_cell"></div>
|
||||
<script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
<table><tr class="module-item"><td><a class="mod" href="race/index.html" title="once_cell::race mod">race</a></td><td class="docblock-short"><p>"First one wins" flavor of <code>OnceCell</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="mod" href="sync/index.html" title="once_cell::sync mod">sync</a></td><td class="docblock-short"></td></tr><tr class="module-item"><td><a class="mod" href="unsync/index.html" title="once_cell::unsync mod">unsync</a></td><td class="docblock-short"></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "once_cell";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
Reference in New Issue
Block a user