Skip to content

Commit a06f7f8

Browse files
committed
Add O(1) Vec -> VecDeque conversion guarantee
1 parent 327b94a commit a06f7f8

File tree

1 file changed

+3
-3
lines changed
  • library/alloc/src/collections/vec_deque

1 file changed

+3
-3
lines changed

Diff for: library/alloc/src/collections/vec_deque/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2789,9 +2789,9 @@ impl<T, A: Allocator> From<Vec<T, A>> for VecDeque<T, A> {
27892789
/// [`Vec<T>`]: crate::vec::Vec
27902790
/// [`VecDeque<T>`]: crate::collections::VecDeque
27912791
///
2792-
/// In its current implementation, this is a very cheap
2793-
/// conversion. This isn't yet a guarantee though, and
2794-
/// shouldn't be relied on.
2792+
/// This conversion is guaranteed to run in *O*(1) time
2793+
/// and to not re-allocate the `Vec`'s buffer or
2794+
/// allocate any additional memory.
27952795
fn from(other: Vec<T, A>) -> Self {
27962796
let (ptr, len, cap, alloc) = other.into_raw_parts_with_alloc();
27972797
Self { head: 0, len, buf: unsafe { RawVec::from_raw_parts_in(ptr, cap, alloc) } }

0 commit comments

Comments
 (0)