From 1ce54d5b5a6ac79b481122c23ab7254e93a1eb57 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 22 Feb 2021 18:49:10 -0600 Subject: [PATCH] chore: change return type of Mandelbrot::generate_image() --- src/main.rs | 2 +- src/mandelbrot.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 08dabaa..abdcdc4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,7 +109,7 @@ fn startup( mut materials: ResMut>, ) { let img_size = Vec2::new(Mandelbrot::width() as f32, Mandelbrot::height() as f32); - let img_buf = Mandelbrot::new().generate_image(); + let img_buf = Mandelbrot::new().generate_image().to_vec(); let texture_handle = textures.add(Texture::new( img_size, diff --git a/src/mandelbrot.rs b/src/mandelbrot.rs index 654c876..0dfe95f 100644 --- a/src/mandelbrot.rs +++ b/src/mandelbrot.rs @@ -26,7 +26,7 @@ impl Mandelbrot { Self::IMG_HEIGHT } - pub fn generate_image(&mut self) -> Vec { + pub fn generate_image(&mut self) -> &[u8] { self.texture_buffer .par_chunks_mut(4) .enumerate() @@ -37,7 +37,7 @@ impl Mandelbrot { buf.copy_from_slice(&Self::hsv_to_rgb(h, 0.6, 1.0)); }); - self.texture_buffer.clone() + &self.texture_buffer } pub fn generate_scaled_image(