From 983aa1b3665c6b546700767d21d73de72372ddad Mon Sep 17 00:00:00 2001 From: Dispersia Date: Mon, 12 Apr 2021 23:23:47 -0700 Subject: [PATCH] Run cargo fmt --- examples/pokedex/src/main.rs | 5 ++++- examples/styling/src/main.rs | 2 +- futures/src/subscription.rs | 3 ++- native/src/widget/pane_grid.rs | 9 ++++---- native/src/widget/text_input/cursor.rs | 4 ++-- native/src/widget/text_input/editor.rs | 4 ++-- src/window/icon.rs | 18 +++++++++------- wgpu/src/image.rs | 29 +++++++++++++------------- wgpu/src/shader/quad.wgsl | 2 +- wgpu/src/triangle/msaa.rs | 29 +++++++++++++------------- 10 files changed, 57 insertions(+), 48 deletions(-) diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs index d2f1bb62..da1d5d5d 100644 --- a/examples/pokedex/src/main.rs +++ b/examples/pokedex/src/main.rs @@ -213,7 +213,10 @@ impl Pokemon { } async fn fetch_image(id: u16) -> Result { - let url = format!("https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/{}.png", id); + let url = format!( + "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/{}.png", + id + ); #[cfg(not(target_arch = "wasm32"))] { diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs index 8975fd9a..4d7dfc48 100644 --- a/examples/styling/src/main.rs +++ b/examples/styling/src/main.rs @@ -44,7 +44,7 @@ impl Sandbox for Styling { match message { Message::ThemeChanged(theme) => self.theme = theme, Message::InputChanged(value) => self.input_value = value, - Message::ButtonPressed => (), + Message::ButtonPressed => {} Message::SliderChanged(value) => self.slider_value = value, Message::CheckboxToggled(value) => self.toggle_value = value, } diff --git a/futures/src/subscription.rs b/futures/src/subscription.rs index 27d2d295..aa81f844 100644 --- a/futures/src/subscription.rs +++ b/futures/src/subscription.rs @@ -78,7 +78,8 @@ where .drain(..) .map(|recipe| { Box::new(With::new(recipe, value.clone())) - as Box> + as + Box> }) .collect(), } diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index 44028f5e..3df7b156 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -209,10 +209,11 @@ where cursor_position: Point, messages: &mut Vec, ) { - let mut clicked_region = - self.elements.iter().zip(layout.children()).filter( - |(_, layout)| layout.bounds().contains(cursor_position), - ); + let mut clicked_region = self + .elements + .iter() + .zip(layout.children()) + .filter(|(_, layout)| layout.bounds().contains(cursor_position)); if let Some(((pane, content), layout)) = clicked_region.next() { if let Some(on_click) = &self.on_click { diff --git a/native/src/widget/text_input/cursor.rs b/native/src/widget/text_input/cursor.rs index 1e7aee83..4f3b159b 100644 --- a/native/src/widget/text_input/cursor.rs +++ b/native/src/widget/text_input/cursor.rs @@ -113,7 +113,7 @@ impl Cursor { State::Selection { start, end } if end > 0 => { self.select_range(start, end - 1) } - _ => (), + _ => {} } } @@ -125,7 +125,7 @@ impl Cursor { State::Selection { start, end } if end < value.len() => { self.select_range(start, end + 1) } - _ => (), + _ => {} } } diff --git a/native/src/widget/text_input/editor.rs b/native/src/widget/text_input/editor.rs index 20e42567..0b50a382 100644 --- a/native/src/widget/text_input/editor.rs +++ b/native/src/widget/text_input/editor.rs @@ -20,7 +20,7 @@ impl<'a> Editor<'a> { self.cursor.move_left(self.value); self.value.remove_many(left, right); } - _ => (), + _ => {} } self.value.insert(self.cursor.end(self.value), character); @@ -35,7 +35,7 @@ impl<'a> Editor<'a> { self.cursor.move_left(self.value); self.value.remove_many(left, right); } - _ => (), + _ => {} } self.value.insert_many(self.cursor.end(self.value), content); diff --git a/src/window/icon.rs b/src/window/icon.rs index 0d27b00e..287538b1 100644 --- a/src/window/icon.rs +++ b/src/window/icon.rs @@ -97,23 +97,25 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Error::InvalidData { byte_count } => { - write!(f, - "The provided RGBA data (with length {:?}) isn't divisble by \ + write!( + f, + "The provided RGBA data (with length {:?}) isn't divisble by \ 4. Therefore, it cannot be safely interpreted as 32bpp RGBA \ pixels.", - byte_count, - ) + byte_count, + ) } Error::DimensionsMismatch { width, height, pixel_count, } => { - write!(f, - "The number of RGBA pixels ({:?}) does not match the provided \ + write!( + f, + "The number of RGBA pixels ({:?}) does not match the provided \ dimensions ({:?}x{:?}).", - pixel_count, width, height, - ) + pixel_count, width, height, + ) } Error::OsError(e) => write!( f, diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 45b63701..78f70dd8 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -134,11 +134,14 @@ impl Pipeline { bind_group_layouts: &[&constant_layout, &texture_layout], }); - let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor { - label: Some("iced_wgpu::image::shader"), - source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader/image.wgsl"))), - flags: wgpu::ShaderFlags::all() - }); + let shader = + device.create_shader_module(&wgpu::ShaderModuleDescriptor { + label: Some("iced_wgpu::image::shader"), + source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed( + include_str!("shader/image.wgsl"), + )), + flags: wgpu::ShaderFlags::all(), + }); let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { @@ -422,16 +425,14 @@ impl Pipeline { let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("iced_wgpu::image render pass"), - color_attachments: &[ - wgpu::RenderPassColorAttachment { - view: target, - resolve_target: None, - ops: wgpu::Operations { - load: wgpu::LoadOp::Load, - store: true, - }, + color_attachments: &[wgpu::RenderPassColorAttachment { + view: target, + resolve_target: None, + ops: wgpu::Operations { + load: wgpu::LoadOp::Load, + store: true, }, - ], + }], depth_stencil_attachment: None, }); diff --git a/wgpu/src/shader/quad.wgsl b/wgpu/src/shader/quad.wgsl index 3c0aa9f2..bae05a0c 100644 --- a/wgpu/src/shader/quad.wgsl +++ b/wgpu/src/shader/quad.wgsl @@ -119,5 +119,5 @@ fn fs_main( input.border_radius + 0.5, dist); - return vec4(radius_alpha, radius_alpha, radius_alpha, radius_alpha); + return vec4(mixed_color.x, mixed_color.y, mixed_color.z, mixed_color.w * radius_alpha); } diff --git a/wgpu/src/triangle/msaa.rs b/wgpu/src/triangle/msaa.rs index d155f3ec..cc19539a 100644 --- a/wgpu/src/triangle/msaa.rs +++ b/wgpu/src/triangle/msaa.rs @@ -74,11 +74,14 @@ impl Blit { bind_group_layouts: &[&constant_layout, &texture_layout], }); - let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor { - label: Some("iced_wgpu::triangle::blit_shader"), - source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("../shader/blit.wgsl"))), - flags: wgpu::ShaderFlags::all() - }); + let shader = + device.create_shader_module(&wgpu::ShaderModuleDescriptor { + label: Some("iced_wgpu::triangle::blit_shader"), + source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed( + include_str!("../shader/blit.wgsl"), + )), + flags: wgpu::ShaderFlags::all(), + }); let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { @@ -176,16 +179,14 @@ impl Blit { let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("iced_wgpu::triangle::msaa render pass"), - color_attachments: &[ - wgpu::RenderPassColorAttachment { - view: target, - resolve_target: None, - ops: wgpu::Operations { - load: wgpu::LoadOp::Load, - store: true, - }, + color_attachments: &[wgpu::RenderPassColorAttachment { + view: target, + resolve_target: None, + ops: wgpu::Operations { + load: wgpu::LoadOp::Load, + store: true, }, - ], + }], depth_stencil_attachment: None, });