difftastic/rustdoc/bumpalo/struct.Bump.html

558 lines
83 KiB
HTML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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="An arena to bump allocate into."><title>Bump in bumpalo - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-ac92e1bbe349e143.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="bumpalo" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.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">&#9776;</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../bumpalo/index.html">bumpalo</a><span class="version">3.16.0</span></h2></div><h2 class="location"><a href="#">Bump</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.alloc">alloc</a></li><li><a href="#method.alloc_layout">alloc_layout</a></li><li><a href="#method.alloc_slice_clone">alloc_slice_clone</a></li><li><a href="#method.alloc_slice_copy">alloc_slice_copy</a></li><li><a href="#method.alloc_slice_fill_clone">alloc_slice_fill_clone</a></li><li><a href="#method.alloc_slice_fill_copy">alloc_slice_fill_copy</a></li><li><a href="#method.alloc_slice_fill_default">alloc_slice_fill_default</a></li><li><a href="#method.alloc_slice_fill_iter">alloc_slice_fill_iter</a></li><li><a href="#method.alloc_slice_fill_with">alloc_slice_fill_with</a></li><li><a href="#method.alloc_str">alloc_str</a></li><li><a href="#method.alloc_try_with">alloc_try_with</a></li><li><a href="#method.alloc_with">alloc_with</a></li><li><a href="#method.allocated_bytes">allocated_bytes</a></li><li><a href="#method.allocated_bytes_including_metadata">allocated_bytes_including_metadata</a></li><li><a href="#method.allocation_limit">allocation_limit</a></li><li><a href="#method.chunk_capacity">chunk_capacity</a></li><li><a href="#method.iter_allocated_chunks">iter_allocated_chunks</a></li><li><a href="#method.iter_allocated_chunks_raw">iter_allocated_chunks_raw</a></li><li><a href="#method.new">new</a></li><li><a href="#method.reset">reset</a></li><li><a href="#method.set_allocation_limit">set_allocation_limit</a></li><li><a href="#method.try_alloc">try_alloc</a></li><li><a href="#method.try_alloc_layout">try_alloc_layout</a></li><li><a href="#method.try_alloc_try_with">try_alloc_try_with</a></li><li><a href="#method.try_alloc_with">try_alloc_with</a></li><li><a href="#method.try_new">try_new</a></li><li><a href="#method.try_with_capacity">try_with_capacity</a></li><li><a href="#method.with_capacity">with_capacity</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-Bump">Debug</a></li><li><a href="#impl-Default-for-Bump">Default</a></li><li><a href="#impl-Drop-for-Bump">Drop</a></li><li><a href="#impl-Send-for-Bump">Send</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-Bump">!RefUnwindSafe</a></li><li><a href="#impl-Sync-for-Bump">!Sync</a></li><li><a href="#impl-UnwindSafe-for-Bump">!UnwindSafe</a></li><li><a href="#impl-Unpin-for-Bump">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-T">From&lt;T&gt;</a></li><li><a href="#impl-Into%3CU%3E-for-T">Into&lt;U&gt;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto&lt;U&gt;</a></li></ul></section><h2><a href="index.html">In crate bumpalo</a></h2></div></nav><div class="sidebar-resizer"></div>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../bumpalo/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="index.html">bumpalo</a>::<wbr><a class="struct" href="#">Bump</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../src/bumpalo/lib.rs.html#292-296">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub struct Bump { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An arena to bump allocate into.</p>
<h3 id="no-drops"><a href="#no-drops">No <code>Drop</code>s</a></h3>
<p>Objects that are bump-allocated will never have their <a href="https://doc.rust-lang.org/std/ops/trait.Drop.html"><code>Drop</code></a> implementation
called — unless you do it manually yourself. This makes it relatively
easy to leak memory or other resources.</p>
<p>If you have a type which internally manages</p>
<ul>
<li>an allocation from the global heap (e.g. <a href="https://doc.rust-lang.org/std/vec/struct.Vec.html"><code>Vec&lt;T&gt;</code></a>),</li>
<li>open file descriptors (e.g. <a href="https://doc.rust-lang.org/std/fs/struct.File.html"><code>std::fs::File</code></a>), or</li>
<li>any other resource that must be cleaned up (e.g. an <code>mmap</code>)</li>
</ul>
<p>and relies on its <code>Drop</code> implementation to clean up the internal resource,
then if you allocate that type with a <code>Bump</code>, you need to find a new way to
clean up after it yourself.</p>
<p>Potential solutions are:</p>
<ul>
<li>
<p>Using <a href="boxed/struct.Box.html#method.new_in"><code>bumpalo::boxed::Box::new_in</code></a> instead of <a href="struct.Bump.html#method.alloc" title="method bumpalo::Bump::alloc"><code>Bump::alloc</code></a>, that
will drop wrapped values similarly to <a href="https://doc.rust-lang.org/std/boxed/struct.Box.html"><code>std::boxed::Box</code></a>. Note that this
requires enabling the <code>&quot;boxed&quot;</code> Cargo feature for this crate. <strong>This is
often the easiest solution.</strong></p>
</li>
<li>
<p>Calling <a href="https://doc.rust-lang.org/std/ptr/fn.drop_in_place.html"><code>drop_in_place</code></a> or using
<a href="https://doc.rust-lang.org/std/mem/struct.ManuallyDrop.html"><code>std::mem::ManuallyDrop</code></a> to manually drop these types.</p>
</li>
<li>
<p>Using <a href="collections/vec/struct.Vec.html"><code>bumpalo::collections::Vec</code></a> instead of <a href="https://doc.rust-lang.org/std/vec/struct.Vec.html"><code>std::vec::Vec</code></a>.</p>
</li>
<li>
<p>Avoiding allocating these problematic types within a <code>Bump</code>.</p>
</li>
</ul>
<p>Note that not calling <code>Drop</code> is memory safe! Destructors are never
guaranteed to run in Rust, you cant rely on them for enforcing memory
safety.</p>
<h3 id="example"><a href="#example">Example</a></h3>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bumpalo::Bump;
<span class="comment">// Create a new bump arena.
</span><span class="kw">let </span>bump = Bump::new();
<span class="comment">// Allocate values into the arena.
</span><span class="kw">let </span>forty_two = bump.alloc(<span class="number">42</span>);
<span class="macro">assert_eq!</span>(<span class="kw-2">*</span>forty_two, <span class="number">42</span>);
<span class="comment">// Mutable references are returned from allocation.
</span><span class="kw">let </span><span class="kw-2">mut </span>s = bump.alloc(<span class="string">"bumpalo"</span>);
<span class="kw-2">*</span>s = <span class="string">"the bump allocator; and also is a buffalo"</span>;</code></pre></div>
<h3 id="allocation-methods-come-in-many-flavors"><a href="#allocation-methods-come-in-many-flavors">Allocation Methods Come in Many Flavors</a></h3>
<p>There are various allocation methods on <code>Bump</code>, the simplest being
<a href="struct.Bump.html#method.alloc" title="method bumpalo::Bump::alloc"><code>alloc</code></a>. The others exist to satisfy some combination of
fallible allocation and initialization. The allocation methods are
summarized in the following table:</p>
<table>
<thead>
<tr>
<th></th>
<th>Infallible Allocation</th>
<th>Fallible Allocation</th>
</tr>
</thead>
<tr>
<th>By Value</th>
<td><a href="#method.alloc"><code>alloc</code></a></td>
<td><a href="#method.try_alloc"><code>try_alloc</code></a></td>
</tr>
<tr>
<th>Infallible Initializer Function</th>
<td><a href="#method.alloc_with"><code>alloc_with</code></a></td>
<td><a href="#method.try_alloc_with"><code>try_alloc_with</code></a></td>
</tr>
<tr>
<th>Fallible Initializer Function</th>
<td><a href="#method.alloc_try_with"><code>alloc_try_with</code></a></td>
<td><a href="#method.try_alloc_try_with"><code>try_alloc_try_with</code></a></td>
</tr>
<tbody>
</tbody>
</table>
<h4 id="fallible-allocation-the-try_alloc_-method-prefix"><a href="#fallible-allocation-the-try_alloc_-method-prefix">Fallible Allocation: The <code>try_alloc_</code> Method Prefix</a></h4>
<p>These allocation methods let you recover from out-of-memory (OOM)
scenarioes, rather than raising a panic on OOM.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bumpalo::Bump;
<span class="kw">let </span>bump = Bump::new();
<span class="kw">match </span>bump.try_alloc(MyStruct {
<span class="comment">// ...
</span>}) {
<span class="prelude-val">Ok</span>(my_struct) =&gt; {
<span class="comment">// Allocation succeeded.
</span>}
<span class="prelude-val">Err</span>(e) =&gt; {
<span class="comment">// Out of memory.
</span>}
}
<span class="kw">struct </span>MyStruct {
<span class="comment">// ...
</span>}</code></pre></div>
<h4 id="initializer-functions-the-_with-method-suffix"><a href="#initializer-functions-the-_with-method-suffix">Initializer Functions: The <code>_with</code> Method Suffix</a></h4>
<p>Calling one of the generic <code>…alloc(x)</code> methods is essentially equivalent to
the matching <a href="?search=alloc_with"><code>…alloc_with(|| x)</code></a>. However if you use
<code>…alloc_with</code>, then the closure will not be invoked until after allocating
space for storing <code>x</code> on the heap.</p>
<p>This can be useful in certain edge-cases related to compiler optimizations.
When evaluating for example <code>bump.alloc(x)</code>, semantically <code>x</code> is first put
on the stack and then moved onto the heap. In some cases, the compiler is
able to optimize this into constructing <code>x</code> directly on the heap, however
in many cases it does not.</p>
<p>The <code>…alloc_with</code> functions try to help the compiler be smarter. In most
cases doing for example <code>bump.try_alloc_with(|| x)</code> on release mode will be
enough to help the compiler realize that this optimization is valid and
to construct <code>x</code> directly onto the heap.</p>
<h5 id="warning"><a href="#warning">Warning</a></h5>
<p>These functions critically depend on compiler optimizations to achieve their
desired effect. This means that it is not an effective tool when compiling
without optimizations on.</p>
<p>Even when optimizations are on, these functions do not <strong>guarantee</strong> that
the value is constructed on the heap. To the best of our knowledge no such
guarantee can be made in stable Rust as of 1.54.</p>
<h4 id="fallible-initialization-the-_try_with-method-suffix"><a href="#fallible-initialization-the-_try_with-method-suffix">Fallible Initialization: The <code>_try_with</code> Method Suffix</a></h4>
<p>The generic <a href="?search=_try_with"><code>…alloc_try_with(|| x)</code></a> methods behave
like the purely <code>_with</code> suffixed methods explained above. However, they
allow for fallible initialization by accepting a closure that returns a
<a href="https://doc.rust-lang.org/std/result/enum.Result.html"><code>Result</code></a> and will attempt to undo the initial allocation if this closure
returns <a href="https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err"><code>Err</code></a>.</p>
<h5 id="warning-1"><a href="#warning-1">Warning</a></h5>
<p>If the inner closure returns <a href="https://doc.rust-lang.org/std/result/enum.Result.html#variant.Ok"><code>Ok</code></a>, space for the entire <a href="https://doc.rust-lang.org/std/result/enum.Result.html"><code>Result</code></a> remains
allocated inside <code>self</code>. This can be a problem especially if the <a href="https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err"><code>Err</code></a>
variant is larger, but even otherwise there may be overhead for the
<a href="https://doc.rust-lang.org/std/result/enum.Result.html"><code>Result</code></a>s discriminant.</p>
<p><details><summary>Undoing the allocation in the <code>Err</code> case
always fails if <code>f</code> successfully made any additional allocations
in <code>self</code>.</summary>
<p>For example, the following will always leak also space for the <a href="https://doc.rust-lang.org/std/result/enum.Result.html"><code>Result</code></a>
into this <code>Bump</code>, even though the inner reference isnt kept and the <a href="https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err"><code>Err</code></a>
payload is returned semantically by value:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>r: <span class="prelude-ty">Result</span>&lt;<span class="kw-2">&amp;mut </span>[u8; <span class="number">1000</span>], ()&gt; = bump.alloc_try_with(|| {
<span class="kw">let _ </span>= bump.alloc(<span class="number">0_u8</span>);
<span class="prelude-val">Err</span>(())
});
<span class="macro">assert!</span>(r.is_err());</code></pre></div>
</details></p>
<p>Since <a href="https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err"><code>Err</code></a> payloads are first placed on the heap and then moved to the
stack, <code>bump.…alloc_try_with(|| x)?</code> is likely to execute more slowly than
the matching <code>bump.…alloc(x?)</code> in case of initialization failure. If this
happens frequently, using the plain un-suffixed method may perform better.</p>
<h4 id="bump-allocation-limits"><a href="#bump-allocation-limits"><code>Bump</code> Allocation Limits</a></h4>
<p><code>bumpalo</code> supports setting a limit on the maximum bytes of memory that can
be allocated for use in a particular <code>Bump</code> arena. This limit can be set and removed with
<a href="struct.Bump.html#method.set_allocation_limit" title="method bumpalo::Bump::set_allocation_limit"><code>set_allocation_limit</code></a>.
The allocation limit is only enforced when allocating new backing chunks for
a <code>Bump</code>. Updating the allocation limit will not affect existing allocations
or any future allocations within the <code>Bump</code>s current chunk.</p>
<h5 id="example-1"><a href="#example-1">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="macro">assert_eq!</span>(bump.allocation_limit(), <span class="prelude-val">None</span>);
bump.set_allocation_limit(<span class="prelude-val">Some</span>(<span class="number">0</span>));
<span class="macro">assert!</span>(bump.try_alloc(<span class="number">5</span>).is_err());
bump.set_allocation_limit(<span class="prelude-val">Some</span>(<span class="number">6</span>));
<span class="macro">assert_eq!</span>(bump.allocation_limit(), <span class="prelude-val">Some</span>(<span class="number">6</span>));
bump.set_allocation_limit(<span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(bump.allocation_limit(), <span class="prelude-val">None</span>);</code></pre></div>
<h5 id="warning-2"><a href="#warning-2">Warning</a></h5>
<p>Because of backwards compatibility, allocations that fail
due to allocation limits will not present differently than
errors due to resource exhaustion.</p>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Bump" class="impl"><a class="src rightside" href="../src/bumpalo/lib.rs.html#493-1829">source</a><a href="#impl-Bump" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#502-504">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h4></section></summary><div class="docblock"><p>Construct a new arena to bump allocate into.</p>
<h6 id="example-2"><a href="#example-2">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_new" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#514-516">source</a><h4 class="code-header">pub fn <a href="#method.try_new" class="fn">try_new</a>() -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a>, <a class="struct" href="struct.AllocErr.html" title="struct bumpalo::AllocErr">AllocErr</a>&gt;</h4></section></summary><div class="docblock"><p>Attempt to construct a new arena to bump allocate into.</p>
<h6 id="example-3"><a href="#example-3">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::try_new();</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_capacity" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#526-528">source</a><h4 class="code-header">pub fn <a href="#method.with_capacity" class="fn">with_capacity</a>(capacity: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h4></section></summary><div class="docblock"><p>Construct a new arena with the specified byte capacity to bump allocate into.</p>
<h6 id="example-4"><a href="#example-4">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::with_capacity(<span class="number">100</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_with_capacity" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#538-561">source</a><h4 class="code-header">pub fn <a href="#method.try_with_capacity" class="fn">try_with_capacity</a>(capacity: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, <a class="struct" href="struct.AllocErr.html" title="struct bumpalo::AllocErr">AllocErr</a>&gt;</h4></section></summary><div class="docblock"><p>Attempt to construct a new arena with the specified byte capacity to bump allocate into.</p>
<h6 id="example-5"><a href="#example-5">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::try_with_capacity(<span class="number">100</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.allocation_limit" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#580-582">source</a><h4 class="code-header">pub fn <a href="#method.allocation_limit" class="fn">allocation_limit</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>The allocation limit for this arena in bytes.</p>
<h6 id="example-6"><a href="#example-6">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::with_capacity(<span class="number">0</span>);
<span class="macro">assert_eq!</span>(bump.allocation_limit(), <span class="prelude-val">None</span>);
bump.set_allocation_limit(<span class="prelude-val">Some</span>(<span class="number">6</span>));
<span class="macro">assert_eq!</span>(bump.allocation_limit(), <span class="prelude-val">Some</span>(<span class="number">6</span>));
bump.set_allocation_limit(<span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(bump.allocation_limit(), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_allocation_limit" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#599-601">source</a><h4 class="code-header">pub fn <a href="#method.set_allocation_limit" class="fn">set_allocation_limit</a>(&amp;self, limit: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>&gt;)</h4></section></summary><div class="docblock"><p>Set the allocation limit in bytes for this arena.</p>
<p>The allocation limit is only enforced when allocating new backing chunks for
a <code>Bump</code>. Updating the allocation limit will not affect existing allocations
or any future allocations within the <code>Bump</code>s current chunk.</p>
<h6 id="example-7"><a href="#example-7">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::with_capacity(<span class="number">0</span>);
bump.set_allocation_limit(<span class="prelude-val">Some</span>(<span class="number">0</span>));
<span class="macro">assert!</span>(bump.try_alloc(<span class="number">5</span>).is_err());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.reset" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#759-795">source</a><h4 class="code-header">pub fn <a href="#method.reset" class="fn">reset</a>(&amp;mut self)</h4></section></summary><div class="docblock"><p>Reset this bump allocator.</p>
<p>Performs mass deallocation on everything allocated in this arena by
resetting the pointer into the underlying chunk of memory to the start
of the chunk. Does not run any <code>Drop</code> implementations on deallocated
objects; see <a href="struct.Bump.html">the top-level documentation</a> for details.</p>
<p>If this arena has allocated multiple chunks to bump allocate into, then
the excess chunks are returned to the global allocator.</p>
<h6 id="example-8"><a href="#example-8">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>bump = bumpalo::Bump::new();
<span class="comment">// Allocate a bunch of things.
</span>{
<span class="kw">for </span>i <span class="kw">in </span><span class="number">0</span>..<span class="number">100 </span>{
bump.alloc(i);
}
}
<span class="comment">// Reset the arena.
</span>bump.reset();
<span class="comment">// Allocate some new things in the space previously occupied by the
// original things.
</span><span class="kw">for </span>j <span class="kw">in </span><span class="number">200</span>..<span class="number">400 </span>{
bump.alloc(j);
}</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#812-814">source</a><h4 class="code-header">pub fn <a href="#method.alloc" class="fn">alloc</a>&lt;T&gt;(&amp;self, val: T) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class="docblock"><p>Allocate an object in this <code>Bump</code> and return an exclusive reference to
it.</p>
<h6 id="panics"><a href="#panics">Panics</a></h6>
<p>Panics if reserving space for <code>T</code> fails.</p>
<h6 id="example-9"><a href="#example-9">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.alloc(<span class="string">"hello"</span>);
<span class="macro">assert_eq!</span>(<span class="kw-2">*</span>x, <span class="string">"hello"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_alloc" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#831-833">source</a><h4 class="code-header">pub fn <a href="#method.try_alloc" class="fn">try_alloc</a>&lt;T&gt;(&amp;self, val: T) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut T</a>, <a class="struct" href="struct.AllocErr.html" title="struct bumpalo::AllocErr">AllocErr</a>&gt;</h4></section></summary><div class="docblock"><p>Try to allocate an object in this <code>Bump</code> and return an exclusive
reference to it.</p>
<h6 id="errors"><a href="#errors">Errors</a></h6>
<p>Errors if reserving space for <code>T</code> fails.</p>
<h6 id="example-10"><a href="#example-10">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.try_alloc(<span class="string">"hello"</span>);
<span class="macro">assert_eq!</span>(x, <span class="prelude-val">Ok</span>(<span class="kw-2">&amp;mut </span><span class="string">"hello"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_with" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#855-885">source</a><h4 class="code-header">pub fn <a href="#method.alloc_with" class="fn">alloc_with</a>&lt;F, T&gt;(&amp;self, f: F) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut T</a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -&gt; T,</div></h4></section></summary><div class="docblock"><p>Pre-allocate space for an object in this <code>Bump</code>, initializes it using
the closure, then returns an exclusive reference to it.</p>
<p>See <a href="#initializer-functions-the-_with-method-suffix">The <code>_with</code> Method Suffix</a> for a
discussion on the differences between the <code>_with</code> suffixed methods and
those methods without it, their performance characteristics, and when
you might or might not choose a <code>_with</code> suffixed method.</p>
<h6 id="panics-1"><a href="#panics-1">Panics</a></h6>
<p>Panics if reserving space for <code>T</code> fails.</p>
<h6 id="example-11"><a href="#example-11">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.alloc_with(|| <span class="string">"hello"</span>);
<span class="macro">assert_eq!</span>(<span class="kw-2">*</span>x, <span class="string">"hello"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_alloc_with" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#907-939">source</a><h4 class="code-header">pub fn <a href="#method.try_alloc_with" class="fn">try_alloc_with</a>&lt;F, T&gt;(&amp;self, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut T</a>, <a class="struct" href="struct.AllocErr.html" title="struct bumpalo::AllocErr">AllocErr</a>&gt;<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -&gt; T,</div></h4></section></summary><div class="docblock"><p>Tries to pre-allocate space for an object in this <code>Bump</code>, initializes
it using the closure, then returns an exclusive reference to it.</p>
<p>See <a href="#initializer-functions-the-_with-method-suffix">The <code>_with</code> Method Suffix</a> for a
discussion on the differences between the <code>_with</code> suffixed methods and
those methods without it, their performance characteristics, and when
you might or might not choose a <code>_with</code> suffixed method.</p>
<h6 id="errors-1"><a href="#errors-1">Errors</a></h6>
<p>Errors if reserving space for <code>T</code> fails.</p>
<h6 id="example-12"><a href="#example-12">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.try_alloc_with(|| <span class="string">"hello"</span>);
<span class="macro">assert_eq!</span>(x, <span class="prelude-val">Ok</span>(<span class="kw-2">&amp;mut </span><span class="string">"hello"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_try_with" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#978-1045">source</a><h4 class="code-header">pub fn <a href="#method.alloc_try_with" class="fn">alloc_try_with</a>&lt;F, T, E&gt;(&amp;self, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut T</a>, E&gt;<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, E&gt;,</div></h4></section></summary><div class="docblock"><p>Pre-allocates space for a <a href="https://doc.rust-lang.org/std/result/enum.Result.html"><code>Result</code></a> in this <code>Bump</code>, initializes it using
the closure, then returns an exclusive reference to its <code>T</code> if <a href="https://doc.rust-lang.org/std/result/enum.Result.html#variant.Ok"><code>Ok</code></a>.</p>
<p>Iff the allocation fails, the closure is not run.</p>
<p>Iff <a href="https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err"><code>Err</code></a>, an allocator rewind is <em>attempted</em> and the <code>E</code> instance is
moved out of the allocator to be consumed or dropped as normal.</p>
<p>See <a href="#initializer-functions-the-_with-method-suffix">The <code>_with</code> Method Suffix</a> for a
discussion on the differences between the <code>_with</code> suffixed methods and
those methods without it, their performance characteristics, and when
you might or might not choose a <code>_with</code> suffixed method.</p>
<p>For caveats specific to fallible initialization, see
<a href="#fallible-initialization-the-_try_with-method-suffix">The <code>_try_with</code> Method Suffix</a>.</p>
<h6 id="errors-2"><a href="#errors-2">Errors</a></h6>
<p>Iff the allocation succeeds but <code>f</code> fails, that error is forwarded by value.</p>
<h6 id="panics-2"><a href="#panics-2">Panics</a></h6>
<p>Panics if reserving space for <code>Result&lt;T, E&gt;</code> fails.</p>
<h6 id="example-13"><a href="#example-13">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.alloc_try_with(|| <span class="prelude-val">Ok</span>(<span class="string">"hello"</span>))<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="kw-2">*</span>x, <span class="string">"hello"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_alloc_try_with" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1086-1153">source</a><h4 class="code-header">pub fn <a href="#method.try_alloc_try_with" class="fn">try_alloc_try_with</a>&lt;F, T, E&gt;(
&amp;self,
f: F
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut T</a>, <a class="enum" href="enum.AllocOrInitError.html" title="enum bumpalo::AllocOrInitError">AllocOrInitError</a>&lt;E&gt;&gt;<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, E&gt;,</div></h4></section></summary><div class="docblock"><p>Tries to pre-allocates space for a <a href="https://doc.rust-lang.org/std/result/enum.Result.html"><code>Result</code></a> in this <code>Bump</code>,
initializes it using the closure, then returns an exclusive reference
to its <code>T</code> if all <a href="https://doc.rust-lang.org/std/result/enum.Result.html#variant.Ok"><code>Ok</code></a>.</p>
<p>Iff the allocation fails, the closure is not run.</p>
<p>Iff the closure returns <a href="https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err"><code>Err</code></a>, an allocator rewind is <em>attempted</em> and
the <code>E</code> instance is moved out of the allocator to be consumed or dropped
as normal.</p>
<p>See <a href="#initializer-functions-the-_with-method-suffix">The <code>_with</code> Method Suffix</a> for a
discussion on the differences between the <code>_with</code> suffixed methods and
those methods without it, their performance characteristics, and when
you might or might not choose a <code>_with</code> suffixed method.</p>
<p>For caveats specific to fallible initialization, see
<a href="#fallible-initialization-the-_try_with-method-suffix">The <code>_try_with</code> Method Suffix</a>.</p>
<h6 id="errors-3"><a href="#errors-3">Errors</a></h6>
<p>Errors with the <a href="enum.AllocOrInitError.html#variant.Alloc" title="variant bumpalo::AllocOrInitError::Alloc"><code>Alloc</code></a> variant iff
reserving space for <code>Result&lt;T, E&gt;</code> fails.</p>
<p>Iff the allocation succeeds but <code>f</code> fails, that error is forwarded by
value inside the <a href="enum.AllocOrInitError.html#variant.Init" title="variant bumpalo::AllocOrInitError::Init"><code>Init</code></a> variant.</p>
<h6 id="example-14"><a href="#example-14">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.try_alloc_try_with(|| <span class="prelude-val">Ok</span>(<span class="string">"hello"</span>))<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="kw-2">*</span>x, <span class="string">"hello"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_slice_copy" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1170-1181">source</a><h4 class="code-header">pub fn <a href="#method.alloc_slice_copy" class="fn">alloc_slice_copy</a>&lt;T&gt;(&amp;self, src: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[T]</a>) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[T]</a><div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a>,</div></h4></section></summary><div class="docblock"><p><code>Copy</code> a slice into this <code>Bump</code> and return an exclusive reference to
the copy.</p>
<h6 id="panics-3"><a href="#panics-3">Panics</a></h6>
<p>Panics if reserving space for the slice fails.</p>
<h6 id="example-15"><a href="#example-15">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.alloc_slice_copy(<span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);
<span class="macro">assert_eq!</span>(x, <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_slice_clone" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1209-1223">source</a><h4 class="code-header">pub fn <a href="#method.alloc_slice_clone" class="fn">alloc_slice_clone</a>&lt;T&gt;(&amp;self, src: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[T]</a>) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[T]</a><div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h4></section></summary><div class="docblock"><p><code>Clone</code> a slice into this <code>Bump</code> and return an exclusive reference to
the clone. Prefer <a href="#method.alloc_slice_copy"><code>alloc_slice_copy</code></a> if <code>T</code> is <code>Copy</code>.</p>
<h6 id="panics-4"><a href="#panics-4">Panics</a></h6>
<p>Panics if reserving space for the slice fails.</p>
<h6 id="example-16"><a href="#example-16">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[derive(Clone, Debug, Eq, PartialEq)]
</span><span class="kw">struct </span>Sheep {
name: String,
}
<span class="kw">let </span>originals = [
Sheep { name: <span class="string">"Alice"</span>.into() },
Sheep { name: <span class="string">"Bob"</span>.into() },
Sheep { name: <span class="string">"Cathy"</span>.into() },
];
<span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>clones = bump.alloc_slice_clone(<span class="kw-2">&amp;</span>originals);
<span class="macro">assert_eq!</span>(originals, clones);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_str" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1239-1245">source</a><h4 class="code-header">pub fn <a href="#method.alloc_str" class="fn">alloc_str</a>(&amp;self, src: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.str.html">str</a>) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p><code>Copy</code> a string slice into this <code>Bump</code> and return an exclusive reference to it.</p>
<h6 id="panics-5"><a href="#panics-5">Panics</a></h6>
<p>Panics if reserving space for the string fails.</p>
<h6 id="example-17"><a href="#example-17">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>hello = bump.alloc_str(<span class="string">"hello world"</span>);
<span class="macro">assert_eq!</span>(<span class="string">"hello world"</span>, hello);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_slice_fill_with" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1265-1281">source</a><h4 class="code-header">pub fn <a href="#method.alloc_slice_fill_with" class="fn">alloc_slice_fill_with</a>&lt;T, F&gt;(&amp;self, len: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>, f: F) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[T]</a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>) -&gt; T,</div></h4></section></summary><div class="docblock"><p>Allocates a new slice of size <code>len</code> into this <code>Bump</code> and returns an
exclusive reference to the copy.</p>
<p>The elements of the slice are initialized using the supplied closure.
The closure argument is the position in the slice.</p>
<h6 id="panics-6"><a href="#panics-6">Panics</a></h6>
<p>Panics if reserving space for the slice fails.</p>
<h6 id="example-18"><a href="#example-18">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.alloc_slice_fill_with(<span class="number">5</span>, |i| <span class="number">5 </span>* (i + <span class="number">1</span>));
<span class="macro">assert_eq!</span>(x, <span class="kw-2">&amp;</span>[<span class="number">5</span>, <span class="number">10</span>, <span class="number">15</span>, <span class="number">20</span>, <span class="number">25</span>]);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_slice_fill_copy" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1300-1302">source</a><h4 class="code-header">pub fn <a href="#method.alloc_slice_fill_copy" class="fn">alloc_slice_fill_copy</a>&lt;T: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a>&gt;(&amp;self, len: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>, value: T) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[T]</a></h4></section></summary><div class="docblock"><p>Allocates a new slice of size <code>len</code> into this <code>Bump</code> and returns an
exclusive reference to the copy.</p>
<p>All elements of the slice are initialized to <code>value</code>.</p>
<h6 id="panics-7"><a href="#panics-7">Panics</a></h6>
<p>Panics if reserving space for the slice fails.</p>
<h6 id="example-19"><a href="#example-19">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.alloc_slice_fill_copy(<span class="number">5</span>, <span class="number">42</span>);
<span class="macro">assert_eq!</span>(x, <span class="kw-2">&amp;</span>[<span class="number">42</span>, <span class="number">42</span>, <span class="number">42</span>, <span class="number">42</span>, <span class="number">42</span>]);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_slice_fill_clone" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1324-1326">source</a><h4 class="code-header">pub fn <a href="#method.alloc_slice_fill_clone" class="fn">alloc_slice_fill_clone</a>&lt;T: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt;(
&amp;self,
len: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>,
value: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;T</a>
) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[T]</a></h4></section></summary><div class="docblock"><p>Allocates a new slice of size <code>len</code> slice into this <code>Bump</code> and return an
exclusive reference to the copy.</p>
<p>All elements of the slice are initialized to <code>value.clone()</code>.</p>
<h6 id="panics-8"><a href="#panics-8">Panics</a></h6>
<p>Panics if reserving space for the slice fails.</p>
<h6 id="example-20"><a href="#example-20">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>s: String = <span class="string">"Hello Bump!"</span>.to_string();
<span class="kw">let </span>x: <span class="kw-2">&amp;</span>[String] = bump.alloc_slice_fill_clone(<span class="number">2</span>, <span class="kw-2">&amp;</span>s);
<span class="macro">assert_eq!</span>(x.len(), <span class="number">2</span>);
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;</span>x[<span class="number">0</span>], <span class="kw-2">&amp;</span>s);
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;</span>x[<span class="number">1</span>], <span class="kw-2">&amp;</span>s);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_slice_fill_iter" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1346-1355">source</a><h4 class="code-header">pub fn <a href="#method.alloc_slice_fill_iter" class="fn">alloc_slice_fill_iter</a>&lt;T, I&gt;(&amp;self, iter: I) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[T]</a><div class="where">where
I: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = T&gt;,
I::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::collect::IntoIterator::IntoIter">IntoIter</a>: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/iter/traits/exact_size/trait.ExactSizeIterator.html" title="trait core::iter::traits::exact_size::ExactSizeIterator">ExactSizeIterator</a>,</div></h4></section></summary><div class="docblock"><p>Allocates a new slice of size <code>len</code> slice into this <code>Bump</code> and return an
exclusive reference to the copy.</p>
<p>The elements are initialized using the supplied iterator.</p>
<h6 id="panics-9"><a href="#panics-9">Panics</a></h6>
<p>Panics if reserving space for the slice fails, or if the supplied
iterator returns fewer elements than it promised.</p>
<h6 id="example-21"><a href="#example-21">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x: <span class="kw-2">&amp;</span>[i32] = bump.alloc_slice_fill_iter([<span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>].iter().cloned().map(|i| i * i));
<span class="macro">assert_eq!</span>(x, [<span class="number">4</span>, <span class="number">9</span>, <span class="number">25</span>]);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_slice_fill_default" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1376-1378">source</a><h4 class="code-header">pub fn <a href="#method.alloc_slice_fill_default" class="fn">alloc_slice_fill_default</a>&lt;T: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a>&gt;(&amp;self, len: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[T]</a></h4></section></summary><div class="docblock"><p>Allocates a new slice of size <code>len</code> slice into this <code>Bump</code> and return an
exclusive reference to the copy.</p>
<p>All elements of the slice are initialized to <a href="https://doc.rust-lang.org/std/default/trait.Default.html#tymethod.default"><code>T::default()</code></a>.</p>
<h6 id="panics-10"><a href="#panics-10">Panics</a></h6>
<p>Panics if reserving space for the slice fails.</p>
<h6 id="example-22"><a href="#example-22">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>x = bump.alloc_slice_fill_default::&lt;u32&gt;(<span class="number">5</span>);
<span class="macro">assert_eq!</span>(x, <span class="kw-2">&amp;</span>[<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>]);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.alloc_layout" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1390-1392">source</a><h4 class="code-header">pub fn <a href="#method.alloc_layout" class="fn">alloc_layout</a>(&amp;self, layout: <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/alloc/layout/struct.Layout.html" title="struct core::alloc::layout::Layout">Layout</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/ptr/non_null/struct.NonNull.html" title="struct core::ptr::non_null::NonNull">NonNull</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.u8.html">u8</a>&gt;</h4></section></summary><div class="docblock"><p>Allocate space for an object with the given <code>Layout</code>.</p>
<p>The returned pointer points at uninitialized memory, and should be
initialized with
<a href="https://doc.rust-lang.org/std/ptr/fn.write.html"><code>std::ptr::write</code></a>.</p>
<h5 id="panics-11"><a href="#panics-11">Panics</a></h5>
<p>Panics if reserving space matching <code>layout</code> fails.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_alloc_layout" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1405-1411">source</a><h4 class="code-header">pub fn <a href="#method.try_alloc_layout" class="fn">try_alloc_layout</a>(&amp;self, layout: <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/alloc/layout/struct.Layout.html" title="struct core::alloc::layout::Layout">Layout</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/ptr/non_null/struct.NonNull.html" title="struct core::ptr::non_null::NonNull">NonNull</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.u8.html">u8</a>&gt;, <a class="struct" href="struct.AllocErr.html" title="struct bumpalo::AllocErr">AllocErr</a>&gt;</h4></section></summary><div class="docblock"><p>Attempts to allocate space for an object with the given <code>Layout</code> or else returns
an <code>Err</code>.</p>
<p>The returned pointer points at uninitialized memory, and should be
initialized with
<a href="https://doc.rust-lang.org/std/ptr/fn.write.html"><code>std::ptr::write</code></a>.</p>
<h5 id="errors-4"><a href="#errors-4">Errors</a></h5>
<p>Errors if reserving space matching <code>layout</code> fails.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.chunk_capacity" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1456-1461">source</a><h4 class="code-header">pub fn <a href="#method.chunk_capacity" class="fn">chunk_capacity</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Gets the remaining capacity in the current chunk (in bytes).</p>
<h6 id="example-23"><a href="#example-23">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bumpalo::Bump;
<span class="kw">let </span>bump = Bump::with_capacity(<span class="number">100</span>);
<span class="kw">let </span>capacity = bump.chunk_capacity();
<span class="macro">assert!</span>(capacity &gt;= <span class="number">100</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_allocated_chunks" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1625-1632">source</a><h4 class="code-header">pub fn <a href="#method.iter_allocated_chunks" class="fn">iter_allocated_chunks</a>(&amp;mut self) -&gt; <a class="struct" href="struct.ChunkIter.html" title="struct bumpalo::ChunkIter">ChunkIter</a>&lt;'_&gt; <a href="#" class="tooltip" data-notable-ty="ChunkIter&lt;&#39;_&gt;"></a></h4></section></summary><div class="docblock"><p>Returns an iterator over each chunk of allocated memory that
this arena has bump allocated into.</p>
<p>The chunks are returned ordered by allocation time, with the most
recently allocated chunk being returned first, and the least recently
allocated chunk being returned last.</p>
<p>The values inside each chunk are also ordered by allocation time, with
the most recent allocation being earlier in the slice, and the least
recent allocation being towards the end of the slice.</p>
<h6 id="safety"><a href="#safety">Safety</a></h6>
<p>Because this method takes <code>&amp;mut self</code>, we know that the bump arena
reference is unique and therefore there arent any active references to
any of the objects weve allocated in it either. This potential aliasing
of exclusive references is one common footgun for unsafe code that we
dont need to worry about here.</p>
<p>However, there could be regions of uninitialized memory used as padding
between allocations, which is why this iterator has items of type
<code>[MaybeUninit&lt;u8&gt;]</code>, instead of simply <code>[u8]</code>.</p>
<p>The only way to guarantee that there is no padding between allocations
or within allocated objects is if all of these properties hold:</p>
<ol>
<li>Every object allocated in this arena has the same alignment,
and that alignment is at most 16.</li>
<li>Every objects size is a multiple of its alignment.</li>
<li>None of the objects allocated in this arena contain any internal
padding.</li>
</ol>
<p>If you want to use this <code>iter_allocated_chunks</code> method, it is <em>your</em>
responsibility to ensure that these properties hold before calling
<code>MaybeUninit::assume_init</code> or otherwise reading the returned values.</p>
<p>Finally, you must also ensure that any values allocated into the bump
arena have not had their <code>Drop</code> implementations called on them,
e.g. after dropping a [<code>bumpalo::boxed::Box&lt;T&gt;</code>][crate::boxed::Box].</p>
<h6 id="example-24"><a href="#example-24">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>bump = bumpalo::Bump::new();
<span class="comment">// Allocate a bunch of `i32`s in this bump arena, potentially causing
// additional memory chunks to be reserved.
</span><span class="kw">for </span>i <span class="kw">in </span><span class="number">0</span>..<span class="number">10000 </span>{
bump.alloc(i);
}
<span class="comment">// Iterate over each chunk we've bump allocated into. This is safe
// because we have only allocated `i32`s in this arena, which fulfills
// the above requirements.
</span><span class="kw">for </span>ch <span class="kw">in </span>bump.iter_allocated_chunks() {
<span class="macro">println!</span>(<span class="string">"Used a chunk that is {} bytes long"</span>, ch.len());
<span class="macro">println!</span>(<span class="string">"The first byte is {:?}"</span>, <span class="kw">unsafe </span>{
ch[<span class="number">0</span>].assume_init()
});
}
<span class="comment">// Within a chunk, allocations are ordered from most recent to least
// recent. If we allocated 'a', then 'b', then 'c', when we iterate
// through the chunk's data, we get them in the order 'c', then 'b',
// then 'a'.
</span>bump.reset();
bump.alloc(<span class="string">b'a'</span>);
bump.alloc(<span class="string">b'b'</span>);
bump.alloc(<span class="string">b'c'</span>);
<span class="macro">assert_eq!</span>(bump.iter_allocated_chunks().count(), <span class="number">1</span>);
<span class="kw">let </span>chunk = bump.iter_allocated_chunks().nth(<span class="number">0</span>).unwrap();
<span class="macro">assert_eq!</span>(chunk.len(), <span class="number">3</span>);
<span class="comment">// Safe because we've only allocated `u8`s in this arena, which
// fulfills the above requirements.
</span><span class="kw">unsafe </span>{
<span class="macro">assert_eq!</span>(chunk[<span class="number">0</span>].assume_init(), <span class="string">b'c'</span>);
<span class="macro">assert_eq!</span>(chunk[<span class="number">1</span>].assume_init(), <span class="string">b'b'</span>);
<span class="macro">assert_eq!</span>(chunk[<span class="number">2</span>].assume_init(), <span class="string">b'a'</span>);
}</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_allocated_chunks_raw" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1651-1656">source</a><h4 class="code-header">pub unsafe fn <a href="#method.iter_allocated_chunks_raw" class="fn">iter_allocated_chunks_raw</a>(&amp;self) -&gt; <a class="struct" href="struct.ChunkRawIter.html" title="struct bumpalo::ChunkRawIter">ChunkRawIter</a>&lt;'_&gt; <a href="#" class="tooltip" data-notable-ty="ChunkRawIter&lt;&#39;_&gt;"></a></h4></section></summary><div class="docblock"><p>Returns an iterator over raw pointers to chunks of allocated memory that
this arena has bump allocated into.</p>
<p>This is an unsafe version of <a href="struct.Bump.html#method.iter_allocated_chunks" title="method bumpalo::Bump::iter_allocated_chunks"><code>iter_allocated_chunks()</code></a>,
with the caller responsible for safe usage of the returned pointers as
well as ensuring that the iterator is not invalidated by new
allocations.</p>
<h6 id="safety-1"><a href="#safety-1">Safety</a></h6>
<p>Allocations from this arena must not be performed while the returned
iterator is alive. If reading the chunk data (or casting to a reference)
the caller must ensure that there exist no mutable references to
previously allocated data.</p>
<p>In addition, all of the caveats when reading the chunk data from
<a href="struct.Bump.html#method.iter_allocated_chunks" title="method bumpalo::Bump::iter_allocated_chunks"><code>iter_allocated_chunks()</code></a> still apply.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.allocated_bytes" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1680-1684">source</a><h4 class="code-header">pub fn <a href="#method.allocated_bytes" class="fn">allocated_bytes</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Calculates the number of bytes currently allocated across all chunks in
this bump arena.</p>
<p>If you allocate types of different alignments or types with
larger-than-typical alignment in the same arena, some padding
bytes might get allocated in the bump arena. Note that those padding
bytes will add to this methods resulting sum, so you cannot rely
on it only counting the sum of the sizes of the things
youve allocated in the arena.</p>
<p>The allocated bytes do not include the size of bumpalos metadata,
so the amount of memory requested from the Rust allocator is higher
than the returned value.</p>
<h6 id="example-25"><a href="#example-25">Example</a></h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>bump = bumpalo::Bump::new();
<span class="kw">let </span>_x = bump.alloc_slice_fill_default::&lt;u32&gt;(<span class="number">5</span>);
<span class="kw">let </span>bytes = bump.allocated_bytes();
<span class="macro">assert!</span>(bytes &gt;= core::mem::size_of::&lt;u32&gt;() * <span class="number">5</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.allocated_bytes_including_metadata" class="method"><a class="src rightside" href="../src/bumpalo/lib.rs.html#1690-1694">source</a><h4 class="code-header">pub fn <a href="#method.allocated_bytes_including_metadata" class="fn">allocated_bytes_including_metadata</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Calculates the number of bytes requested from the Rust allocator for this <code>Bump</code>.</p>
<p>This number is equal to the <a href="struct.Bump.html#method.allocated_bytes" title="method bumpalo::Bump::allocated_bytes"><code>allocated_bytes()</code></a> plus
the size of the bump metadata.</p>
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Bump" class="impl"><a class="src rightside" href="../src/bumpalo/lib.rs.html#291">source</a><a href="#impl-Debug-for-Bump" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/bumpalo/lib.rs.html#291">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Default-for-Bump" class="impl"><a class="src rightside" href="../src/bumpalo/lib.rs.html#380-384">source</a><a href="#impl-Default-for-Bump" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.default" class="method trait-impl"><a class="src rightside" href="../src/bumpalo/lib.rs.html#381-383">source</a><a href="#method.default" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/default/trait.Default.html#tymethod.default" class="fn">default</a>() -&gt; <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/1.76.0/core/default/trait.Default.html#tymethod.default">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Drop-for-Bump" class="impl"><a class="src rightside" href="../src/bumpalo/lib.rs.html#386-392">source</a><a href="#impl-Drop-for-Bump" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl"><a class="src rightside" href="../src/bumpalo/lib.rs.html#387-391">source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/ops/drop/trait.Drop.html#tymethod.drop" class="fn">drop</a>(&amp;mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a href="https://doc.rust-lang.org/1.76.0/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></div></details></div></details><section id="impl-Send-for-Bump" class="impl"><a class="src rightside" href="../src/bumpalo/lib.rs.html#407">source</a><a href="#impl-Send-for-Bump" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-Bump" class="impl"><a href="#impl-RefUnwindSafe-for-Bump" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h3></section><section id="impl-Sync-for-Bump" class="impl"><a href="#impl-Sync-for-Bump" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h3></section><section id="impl-Unpin-for-Bump" class="impl"><a href="#impl-Unpin-for-Bump" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h3></section><section id="impl-UnwindSafe-for-Bump" class="impl"><a href="#impl-UnwindSafe-for-Bump" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Bump.html" title="struct bumpalo::Bump">Bump</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#763">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#766">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#747-749">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#756">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; 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><a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#803-805">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#810">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#788-790">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#795">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div><script type="text/json" id="notable-traits-data">{"ChunkIter<'_>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.ChunkIter.html\" title=\"struct bumpalo::ChunkIter\">ChunkIter</a>&lt;'a&gt;</code></h3><pre><code><div class=\"where\">impl&lt;'a&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"struct.ChunkIter.html\" title=\"struct bumpalo::ChunkIter\">ChunkIter</a>&lt;'a&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = &amp;'a [<a class=\"union\" href=\"https://doc.rust-lang.org/1.76.0/core/mem/maybe_uninit/union.MaybeUninit.html\" title=\"union core::mem::maybe_uninit::MaybeUninit\">MaybeUninit</a>&lt;<a class=\"primitive\" href=\"https://doc.rust-lang.org/1.76.0/core/primitive.u8.html\">u8</a>&gt;];</div>","ChunkRawIter<'_>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.ChunkRawIter.html\" title=\"struct bumpalo::ChunkRawIter\">ChunkRawIter</a>&lt;'_&gt;</code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"struct.ChunkRawIter.html\" title=\"struct bumpalo::ChunkRawIter\">ChunkRawIter</a>&lt;'_&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = (<a class=\"primitive\" href=\"https://doc.rust-lang.org/1.76.0/core/primitive.pointer.html\">*mut </a><a class=\"primitive\" href=\"https://doc.rust-lang.org/1.76.0/core/primitive.u8.html\">u8</a>, <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.76.0/core/primitive.usize.html\">usize</a>);</div>"}</script></section></div></main></body></html>