File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ extern crate alloc;
37
37
#[ cfg( any( test, feature = "write" ) ) ]
38
38
extern crate std;
39
39
40
+ use alloc:: boxed:: Box ;
40
41
use alloc:: vec:: Vec ;
41
42
use core:: borrow:: { Borrow , BorrowMut } ;
42
43
use core:: cmp;
@@ -893,6 +894,14 @@ impl<A: Array> SmallVec<A> {
893
894
}
894
895
}
895
896
897
+ /// Converts a `SmallVec` into a `Box<[T]>` without reallocating if the `SmallVec` has already spilled
898
+ /// onto the heap.
899
+ ///
900
+ /// Note that this will drop any excess capacity.
901
+ pub fn into_boxed_slice ( self ) -> Box < [ A :: Item ] > {
902
+ self . into_vec ( ) . into_boxed_slice ( )
903
+ }
904
+
896
905
/// Convert the SmallVec into an `A` if possible. Otherwise return `Err(Self)`.
897
906
///
898
907
/// This method returns `Err(Self)` if the SmallVec is too short (and the `A` contains uninitialized elements),
You can’t perform that action at this time.
0 commit comments