diff options
| author | Jacob Asper <jacobasper191@gmail.com> | 2024-02-18 17:55:52 -0500 |
|---|---|---|
| committer | Jacob Asper <jacobasper191@gmail.com> | 2024-02-18 17:55:52 -0500 |
| commit | bc52e5d4de4a41f41e9849e564c955ce3d1fe513 (patch) | |
| tree | cae88a5ca25b3ec90e5eb9320368a193a1faaf92 | |
| parent | a9cfeb34ddd4b859042f8d8f02ae96a0dbf8574b (diff) | |
| download | rust-bc52e5d4de4a41f41e9849e564c955ce3d1fe513.tar.gz rust-bc52e5d4de4a41f41e9849e564c955ce3d1fe513.zip | |
Fix error in push docs
Copying is O(n)—not the memory allocation
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index b4eee69e31f..bd36b55d782 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1921,10 +1921,11 @@ impl<T, A: Allocator> Vec<T, A> { /// /// # Time complexity /// - /// Takes amortized *O*(1) time. If the vector's length would exceed its capacity after - /// the push, *O*(*capacity*) space is allocated, doubling the capacity and - /// taking *O*(*capacity*) time. This expensive operation is offset by the - /// *capacity* *O*(1) insertions it allows. + /// Takes amortized *O*(1) time. If the vector's length would exceed its + /// capacity after the push, the capacity is doubled by allocating + /// *O*(*capacity*) space, then *O*(*capacity*) time to copy the vector's + /// elements. This expensive operation is offset by the *capacity* *O*(1) + /// insertions it allows. #[cfg(not(no_global_oom_handling))] #[inline] #[stable(feature = "rust1", since = "1.0.0")] |
