From dada50c68ab59275e97f87097ce21e06891c7267 Mon Sep 17 00:00:00 2001 From: Marc Liu Date: Sun, 15 Aug 2021 20:47:56 -0400 Subject: [PATCH] Fix capacities for rows and row. If I understand correctly, the number of rows should be the value of height, not width. Similarly, the number of items in each `row` should be the value of width. --- ch2/ch2-mandelbrot/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ch2/ch2-mandelbrot/src/main.rs b/ch2/ch2-mandelbrot/src/main.rs index f7c6530e..2a84e71c 100644 --- a/ch2/ch2-mandelbrot/src/main.rs +++ b/ch2/ch2-mandelbrot/src/main.rs @@ -11,10 +11,10 @@ fn calculate_mandelbrot( // <2> height: usize, // <5> ) -> Vec> { - let mut rows: Vec<_> = Vec::with_capacity(width); // <6> + let mut rows: Vec<_> = Vec::with_capacity(height); // <6> for img_y in 0..height { // <7> - let mut row: Vec = Vec::with_capacity(height); + let mut row: Vec = Vec::with_capacity(width); for img_x in 0..width { let x_percent = (img_x as f64 / width as f64);