diff options
| author | Markus Everling <markuseverling@gmail.com> | 2022-12-01 12:21:12 +0100 |
|---|---|---|
| committer | Markus Everling <markuseverling@gmail.com> | 2022-12-05 14:57:22 +0100 |
| commit | ac583f18b75f005023b41d49298d4d343740648a (patch) | |
| tree | 7741b5b9bd3ce2aae0e5d675909bb6c1bb312842 | |
| parent | 203c8765ea33c65d888febe0e8219c4bb11b0d89 (diff) | |
| download | rust-ac583f18b75f005023b41d49298d4d343740648a.tar.gz rust-ac583f18b75f005023b41d49298d4d343740648a.zip | |
Add O(1) `Vec -> VecDeque` conversion guarantee
| -rw-r--r-- | library/alloc/src/collections/vec_deque/mod.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 4866c53e7d5..0645f2ae4da 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -2794,9 +2794,9 @@ impl<T, A: Allocator> From<Vec<T, A>> for VecDeque<T, A> { /// [`Vec<T>`]: crate::vec::Vec /// [`VecDeque<T>`]: crate::collections::VecDeque /// - /// In its current implementation, this is a very cheap - /// conversion. This isn't yet a guarantee though, and - /// shouldn't be relied on. + /// This conversion is guaranteed to run in *O*(1) time + /// and to not re-allocate the `Vec`'s buffer or allocate + /// any additional memory. #[inline] fn from(other: Vec<T, A>) -> Self { let (ptr, len, cap, alloc) = other.into_raw_parts_with_alloc(); |
