Skip to content

Commit fcfc17f

Browse files
author
balt-dev
committed
Add forgotten bounds check
1 parent 01ee4b7 commit fcfc17f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/alloc/src/vec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,7 @@ impl<T, A: Allocator> Vec<T, A> {
20322032
#[stable(feature = "rust1", since = "1.0.0")]
20332033
#[track_caller]
20342034
pub fn insert(&mut self, index: usize, element: T) {
2035-
let _ = self.insert_mut(index, element);
2035+
assert!(self.insert_mut(index, element).is_some(), "index out of bounds");
20362036
}
20372037

20382038
/// Inserts an element at position `index` within the vector, shifting all

0 commit comments

Comments
 (0)