We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6556549 commit 86c1c43Copy full SHA for 86c1c43
src/liballoc/vec.rs
@@ -2019,6 +2019,8 @@ where
2019
let (lower, _) = iterator.size_hint();
2020
let mut vector = Vec::with_capacity(lower.saturating_add(1));
2021
unsafe {
2022
+ // `vector` is new, cannot have aliases, so us getting exclusive references
2023
+ // here is okay.
2024
ptr::write(vector.get_unchecked_mut(0), element);
2025
vector.set_len(1);
2026
}
@@ -2145,7 +2147,7 @@ impl<T> Vec<T> {
2145
2147
self.reserve(lower.saturating_add(1));
2146
2148
2149
- ptr::write(self.get_unchecked_mut(len), element);
2150
+ ptr::write(self.as_mut_ptr().add(len), element);
2151
// NB can't overflow since we would have had to alloc the address space
2152
self.set_len(len + 1);
2153
0 commit comments