File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,10 +140,16 @@ assert_eq!(size_of_val(&v), 3 * size_of::<usize>());
140140let bs : Box <[u32 ]> = v . into_boxed_slice ();
141141assert_eq! (size_of_val (& bs ), 2 * size_of :: <usize >());
142142```
143- The boxed slice can be converted back to a vector with [ ` slice::into_vec ` ]
144- without any cloning or a reallocation.
143+ Alternatively, a boxed slice can be constructed directly from an iterator with
144+ [ ` Iterator::collect ` ] , avoiding the need for any reallocation.
145+ ``` rust
146+ let bs : Box <[u32 ]> = (1 .. 3 ). collect ();
147+ ```
148+ A boxed slice can be converted to a vector with [ ` slice::into_vec ` ] without any
149+ cloning or reallocation.
145150
146151[ `Vec::into_boxed_slice` ] : https://doc.rust-lang.org/std/vec/struct.Vec.html#method.into_boxed_slice
152+ [ `Iterator::collect` ] : https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect
147153[ `slice::into_vec` ] : https://doc.rust-lang.org/std/primitive.slice.html#method.into_vec
148154
149155## ` ThinVec `
You can’t perform that action at this time.
0 commit comments