From: Tomas Wenström Date: Fri, 15 Feb 2019 20:48:17 +0000 (+0100) Subject: Unnecessary mutability X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=a4088bfb5219aeb929cdfc0f874d7bb95b1031cd;p=kaka%2Frust-sdl-test.git Unnecessary mutability --- diff --git a/src/boll.rs b/src/boll.rs index 35dd97e..64be265 100644 --- a/src/boll.rs +++ b/src/boll.rs @@ -10,7 +10,7 @@ use sdl2::gfx::primitives::DrawRenderer; pub trait Boll { fn update(&mut self); - fn draw(&mut self, canvas: &mut Canvas, size: u32); + fn draw(&self, canvas: &mut Canvas, size: u32); } pub struct SquareBoll { @@ -41,7 +41,7 @@ impl Boll for SquareBoll { } } - fn draw(&mut self, canvas: &mut Canvas, size: u32) { + fn draw(&self, canvas: &mut Canvas, size: u32) { canvas.set_draw_color(Color::RGBA( 255 - std::cmp::min(255, (self.vel.length() * 25.0) as u8), (255.0 * (self.pos.x / SCREEN_WIDTH as f64)) as u8, @@ -74,7 +74,7 @@ impl Boll for CircleBoll { self.boll.update(); } - fn draw(&mut self, canvas: &mut Canvas, size: u32) { + fn draw(&self, canvas: &mut Canvas, size: u32) { let val = 255 - std::cmp::min(255, (self.boll.vel.length() * 20.0) as u8); canvas.filled_circle(self.boll.pos.x as i16, self.boll.pos.y as i16, size as i16, Color::RGBA( val,