Skip to content

Commit bc52e5d

Browse files
committed
Fix error in push docs
Copying is O(n)—not the memory allocation
1 parent a9cfeb3 commit bc52e5d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

library/alloc/src/vec/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1921,10 +1921,11 @@ impl<T, A: Allocator> Vec<T, A> {
19211921
///
19221922
/// # Time complexity
19231923
///
1924-
/// Takes amortized *O*(1) time. If the vector's length would exceed its capacity after
1925-
/// the push, *O*(*capacity*) space is allocated, doubling the capacity and
1926-
/// taking *O*(*capacity*) time. This expensive operation is offset by the
1927-
/// *capacity* *O*(1) insertions it allows.
1924+
/// Takes amortized *O*(1) time. If the vector's length would exceed its
1925+
/// capacity after the push, the capacity is doubled by allocating
1926+
/// *O*(*capacity*) space, then *O*(*capacity*) time to copy the vector's
1927+
/// elements. This expensive operation is offset by the *capacity* *O*(1)
1928+
/// insertions it allows.
19281929
#[cfg(not(no_global_oom_handling))]
19291930
#[inline]
19301931
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)