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 f8493d0 commit ac617b6Copy full SHA for ac617b6
src/libcollections/vec.rs
@@ -309,10 +309,10 @@ impl<T> Vec<T> {
309
#[stable(feature = "rust1", since = "1.0.0")]
310
pub fn reserve(&mut self, additional: usize) {
311
if self.cap - self.len < additional {
312
- let err_msg = "Vec::reserve: `isize` overflow";
+ const ERR_MSG: &'static str = "Vec::reserve: `isize` overflow";
313
314
- let new_min_cap = self.len.checked_add(additional).expect(err_msg);
315
- if new_min_cap > MAX_MEMORY_SIZE { panic!(err_msg) }
+ let new_min_cap = self.len.checked_add(additional).expect(ERR_MSG);
+ if new_min_cap > MAX_MEMORY_SIZE { panic!(ERR_MSG) }
316
self.grow_capacity(match new_min_cap.checked_next_power_of_two() {
317
Some(x) if x > MAX_MEMORY_SIZE => MAX_MEMORY_SIZE,
318
None => MAX_MEMORY_SIZE,
0 commit comments