Skip to content

Commit e0ee3a4

Browse files
committed
deploy: 74f175e
1 parent 1573a35 commit e0ee3a4

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

print.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,8 +1269,14 @@ <h2 id="boxed-slices"><a class="header" href="#boxed-slices">Boxed Slices</a></h
12691269
let bs: Box&lt;[u32]&gt; = v.into_boxed_slice();
12701270
assert_eq!(size_of_val(&amp;bs), 2 * size_of::&lt;usize&gt;());
12711271
<span class="boring">}</span></code></pre></pre>
1272-
<p>The boxed slice can be converted back to a vector with <a href="https://doc.rust-lang.org/std/primitive.slice.html#method.into_vec"><code>slice::into_vec</code></a>
1273-
without any cloning or a reallocation.</p>
1272+
<p>Alternatively, a boxed slice can be constructed directly from an iterator with
1273+
<a href="https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect"><code>Iterator::collect</code></a>, avoiding the need for any reallocation.</p>
1274+
<pre><pre class="playground"><code class="language-rust edition2018"><span class="boring">#![allow(unused)]
1275+
</span><span class="boring">fn main() {
1276+
</span>let bs: Box&lt;[u32]&gt; = (1..3).collect();
1277+
<span class="boring">}</span></code></pre></pre>
1278+
<p>A boxed slice can be converted to a vector with <a href="https://doc.rust-lang.org/std/primitive.slice.html#method.into_vec"><code>slice::into_vec</code></a> without any
1279+
cloning or reallocation.</p>
12741280
<h2 id="thinvec"><a class="header" href="#thinvec"><code>ThinVec</code></a></h2>
12751281
<p>An alternative to boxed slices is <code>ThinVec</code>, from the <a href="https://crates.io/crates/thin-vec"><code>thin_vec</code></a> crate. It is
12761282
functionally equivalent to <code>Vec</code>, but stores the length and capacity in the

searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

type-sizes.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,14 @@ <h2 id="boxed-slices"><a class="header" href="#boxed-slices">Boxed Slices</a></h
304304
let bs: Box&lt;[u32]&gt; = v.into_boxed_slice();
305305
assert_eq!(size_of_val(&amp;bs), 2 * size_of::&lt;usize&gt;());
306306
<span class="boring">}</span></code></pre></pre>
307-
<p>The boxed slice can be converted back to a vector with <a href="https://doc.rust-lang.org/std/primitive.slice.html#method.into_vec"><code>slice::into_vec</code></a>
308-
without any cloning or a reallocation.</p>
307+
<p>Alternatively, a boxed slice can be constructed directly from an iterator with
308+
<a href="https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect"><code>Iterator::collect</code></a>, avoiding the need for any reallocation.</p>
309+
<pre><pre class="playground"><code class="language-rust edition2018"><span class="boring">#![allow(unused)]
310+
</span><span class="boring">fn main() {
311+
</span>let bs: Box&lt;[u32]&gt; = (1..3).collect();
312+
<span class="boring">}</span></code></pre></pre>
313+
<p>A boxed slice can be converted to a vector with <a href="https://doc.rust-lang.org/std/primitive.slice.html#method.into_vec"><code>slice::into_vec</code></a> without any
314+
cloning or reallocation.</p>
309315
<h2 id="thinvec"><a class="header" href="#thinvec"><code>ThinVec</code></a></h2>
310316
<p>An alternative to boxed slices is <code>ThinVec</code>, from the <a href="https://crates.io/crates/thin-vec"><code>thin_vec</code></a> crate. It is
311317
functionally equivalent to <code>Vec</code>, but stores the length and capacity in the

0 commit comments

Comments
 (0)