vec/raw: Simplify `RawVec::grow` (#392)
diff --git a/src/vec/vec-raw.md b/src/vec/vec-raw.md
index 728feaa..0bca2da 100644
--- a/src/vec/vec-raw.md
+++ b/src/vec/vec-raw.md
@@ -28,18 +28,13 @@
}
fn grow(&mut self) {
- let (new_cap, new_layout) = if self.cap == 0 {
- (1, Layout::array::<T>(1).unwrap())
- } else {
- // This can't overflow because we ensure self.cap <= isize::MAX.
- let new_cap = 2 * self.cap;
+ // This can't overflow because we ensure self.cap <= isize::MAX.
+ let new_cap = if self.cap == 0 { 1 } else { 2 * self.cap };
- // Layout::array checks that the number of bytes is <= usize::MAX,
- // but this is redundant since old_layout.size() <= isize::MAX,
- // so the `unwrap` should never fail.
- let new_layout = Layout::array::<T>(new_cap).unwrap();
- (new_cap, new_layout)
- };
+ // Layout::array checks that the number of bytes is <= usize::MAX,
+ // but this is redundant since old_layout.size() <= isize::MAX,
+ // so the `unwrap` should never fail.
+ let new_layout = Layout::array::<T>(new_cap).unwrap();
// Ensure that the new allocation doesn't exceed `isize::MAX` bytes.
assert!(new_layout.size() <= isize::MAX as usize, "Allocation too large");