Skip to content

Commit 59a4d73

Browse files
Update library/alloc/src/vec/mod.rs
Co-authored-by: Jonas Böttiger <[email protected]>
1 parent 35439de commit 59a4d73

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/alloc/src/vec/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,10 @@ impl<T, A: Allocator> Vec<T, A> {
22002200
panic!("removal index (is {index}) should be < len (is {len})");
22012201
}
22022202

2203-
self.try_remove(index).unwrap_or_else(|| assert_failed(index, self.len()))
2203+
match self.try_remove(index) {
2204+
Some(elem) => elem,
2205+
None => assert_failed(index, self.len()),
2206+
}
22042207
}
22052208

22062209
/// Remove and return the element at position `index` within the vector,

0 commit comments

Comments
 (0)