From 9bfed17a7f51733f9042b3b524405229c628003b Mon Sep 17 00:00:00 2001 From: Jay Oster Date: Mon, 29 Mar 2021 00:52:43 -0700 Subject: [PATCH] Various fixes (#154) * Cargo clippy * Fix typo --- MSRV.md | 2 +- examples/invaders/simple-invaders/src/lib.rs | 6 ++---- internals/pixels-mocks/src/lib.rs | 4 ++-- src/builder.rs | 8 ++++---- src/lib.rs | 10 +++++----- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/MSRV.md b/MSRV.md index a447a26..a198703 100644 --- a/MSRV.md +++ b/MSRV.md @@ -12,6 +12,6 @@ ## Policy -The table above will be kept to up-to-date in lock-step with CI on the main branch in GitHub. It may contain information about unreleased and yanked versions. It is the user's responsibility to consult with the [`pixels` versions page](https://crates.io/crates/pixels/versions) on `crates.io` to verify version status. +The table above will be kept up-to-date in lock-step with CI on the main branch in GitHub. It may contain information about unreleased and yanked versions. It is the user's responsibility to consult with the [`pixels` versions page](https://crates.io/crates/pixels/versions) on `crates.io` to verify version status. The MSRV will be chosen as the minimum version of `rustc` that can successfully pass CI, including documentation, lints, and all examples. For this reason, the minimum version _supported_ may be higher than the minimum version _required_ to compile the `pixels` crate itself. diff --git a/examples/invaders/simple-invaders/src/lib.rs b/examples/invaders/simple-invaders/src/lib.rs index 825cbe9..7ca34e2 100644 --- a/examples/invaders/simple-invaders/src/lib.rs +++ b/examples/invaders/simple-invaders/src/lib.rs @@ -287,10 +287,8 @@ impl World { // Draw the invaders for row in &self.invaders.grid { - for col in row { - if let Some(invader) = col { - blit(screen, &invader.pos, &invader.sprite); - } + for invader in row.iter().flatten() { + blit(screen, &invader.pos, &invader.sprite); } } diff --git a/internals/pixels-mocks/src/lib.rs b/internals/pixels-mocks/src/lib.rs index 2785a00..fef1b1b 100644 --- a/internals/pixels-mocks/src/lib.rs +++ b/internals/pixels-mocks/src/lib.rs @@ -1,8 +1,8 @@ #![deny(clippy::all)] -pub struct RWH; +pub struct Rwh; -unsafe impl raw_window_handle::HasRawWindowHandle for RWH { +unsafe impl raw_window_handle::HasRawWindowHandle for Rwh { fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle { #[cfg(target_os = "macos")] return raw_window_handle::RawWindowHandle::MacOS( diff --git a/src/builder.rs b/src/builder.rs index ece169a..6ead492 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -11,7 +11,7 @@ pub struct PixelsBuilder<'req, 'dev, 'win, W: HasRawWindowHandle> { backend: wgpu::BackendBit, width: u32, height: u32, - pixel_aspect_ratio: f64, + _pixel_aspect_ratio: f64, present_mode: wgpu::PresentMode, surface_texture: SurfaceTexture<'win, W>, texture_format: wgpu::TextureFormat, @@ -25,7 +25,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W> /// /// ```no_run /// # use pixels::PixelsBuilder; - /// # let window = pixels_mocks::RWH; + /// # let window = pixels_mocks::Rwh; /// # let surface_texture = pixels::SurfaceTexture::new(1024, 768, &window); /// let mut pixels = PixelsBuilder::new(256, 240, surface_texture) /// .request_adapter_options(wgpu::RequestAdapterOptions { @@ -54,7 +54,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W> backend: wgpu::BackendBit::PRIMARY, width, height, - pixel_aspect_ratio: 1.0, + _pixel_aspect_ratio: 1.0, present_mode: wgpu::PresentMode::Fifo, surface_texture, texture_format: wgpu::TextureFormat::Rgba8UnormSrgb, @@ -110,7 +110,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W> ) -> PixelsBuilder<'req, 'dev, 'win, W> { assert!(pixel_aspect_ratio > 0.0); - self.pixel_aspect_ratio = pixel_aspect_ratio; + self._pixel_aspect_ratio = pixel_aspect_ratio; self } diff --git a/src/lib.rs b/src/lib.rs index 95d3f03..f0b1fbd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -170,7 +170,7 @@ impl Pixels { /// /// ```no_run /// # use pixels::Pixels; - /// # let window = pixels_mocks::RWH; + /// # let window = pixels_mocks::Rwh; /// # let surface_texture = pixels::SurfaceTexture::new(1024, 768, &window); /// let mut pixels = Pixels::new(320, 240, surface_texture)?; /// # Ok::<(), pixels::Error>(()) @@ -272,7 +272,7 @@ impl Pixels { /// /// ```no_run /// # use pixels::Pixels; - /// # let window = pixels_mocks::RWH; + /// # let window = pixels_mocks::Rwh; /// # let surface_texture = pixels::SurfaceTexture::new(1024, 768, &window); /// let mut pixels = Pixels::new(320, 240, surface_texture)?; /// @@ -310,7 +310,7 @@ impl Pixels { /// /// ```no_run /// # use pixels::Pixels; - /// # let window = pixels_mocks::RWH; + /// # let window = pixels_mocks::Rwh; /// # let surface_texture = pixels::SurfaceTexture::new(1024, 768, &window); /// let mut pixels = Pixels::new(320, 240, surface_texture)?; /// @@ -411,7 +411,7 @@ impl Pixels { /// /// ```no_run /// # use pixels::Pixels; - /// # let window = pixels_mocks::RWH; + /// # let window = pixels_mocks::Rwh; /// # let surface_texture = pixels::SurfaceTexture::new(1024, 768, &window); /// const WIDTH: u32 = 320; /// const HEIGHT: u32 = 240; @@ -471,7 +471,7 @@ impl Pixels { /// /// ```no_run /// # use pixels::Pixels; - /// # let window = pixels_mocks::RWH; + /// # let window = pixels_mocks::Rwh; /// # let surface_texture = pixels::SurfaceTexture::new(1024, 768, &window); /// const WIDTH: u32 = 320; /// const HEIGHT: u32 = 240;