Run cargo fmt

This commit is contained in:
Dispersia 2021-04-12 23:23:47 -07:00
parent 0722d5e3ec
commit 983aa1b366
10 changed files with 57 additions and 48 deletions

View File

@ -213,7 +213,10 @@ impl Pokemon {
} }
async fn fetch_image(id: u16) -> Result<image::Handle, reqwest::Error> { async fn fetch_image(id: u16) -> Result<image::Handle, reqwest::Error> {
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"))] #[cfg(not(target_arch = "wasm32"))]
{ {

View File

@ -44,7 +44,7 @@ impl Sandbox for Styling {
match message { match message {
Message::ThemeChanged(theme) => self.theme = theme, Message::ThemeChanged(theme) => self.theme = theme,
Message::InputChanged(value) => self.input_value = value, Message::InputChanged(value) => self.input_value = value,
Message::ButtonPressed => (), Message::ButtonPressed => {}
Message::SliderChanged(value) => self.slider_value = value, Message::SliderChanged(value) => self.slider_value = value,
Message::CheckboxToggled(value) => self.toggle_value = value, Message::CheckboxToggled(value) => self.toggle_value = value,
} }

View File

@ -78,7 +78,8 @@ where
.drain(..) .drain(..)
.map(|recipe| { .map(|recipe| {
Box::new(With::new(recipe, value.clone())) Box::new(With::new(recipe, value.clone()))
as Box<dyn Recipe<H, E, Output = (T, O)>> as
Box<dyn Recipe<H, E, Output = (T, O)>>
}) })
.collect(), .collect(),
} }

View File

@ -209,10 +209,11 @@ where
cursor_position: Point, cursor_position: Point,
messages: &mut Vec<Message>, messages: &mut Vec<Message>,
) { ) {
let mut clicked_region = let mut clicked_region = self
self.elements.iter().zip(layout.children()).filter( .elements
|(_, layout)| layout.bounds().contains(cursor_position), .iter()
); .zip(layout.children())
.filter(|(_, layout)| layout.bounds().contains(cursor_position));
if let Some(((pane, content), layout)) = clicked_region.next() { if let Some(((pane, content), layout)) = clicked_region.next() {
if let Some(on_click) = &self.on_click { if let Some(on_click) = &self.on_click {

View File

@ -113,7 +113,7 @@ impl Cursor {
State::Selection { start, end } if end > 0 => { State::Selection { start, end } if end > 0 => {
self.select_range(start, end - 1) self.select_range(start, end - 1)
} }
_ => (), _ => {}
} }
} }
@ -125,7 +125,7 @@ impl Cursor {
State::Selection { start, end } if end < value.len() => { State::Selection { start, end } if end < value.len() => {
self.select_range(start, end + 1) self.select_range(start, end + 1)
} }
_ => (), _ => {}
} }
} }

View File

@ -20,7 +20,7 @@ impl<'a> Editor<'a> {
self.cursor.move_left(self.value); self.cursor.move_left(self.value);
self.value.remove_many(left, right); self.value.remove_many(left, right);
} }
_ => (), _ => {}
} }
self.value.insert(self.cursor.end(self.value), character); self.value.insert(self.cursor.end(self.value), character);
@ -35,7 +35,7 @@ impl<'a> Editor<'a> {
self.cursor.move_left(self.value); self.cursor.move_left(self.value);
self.value.remove_many(left, right); self.value.remove_many(left, right);
} }
_ => (), _ => {}
} }
self.value.insert_many(self.cursor.end(self.value), content); self.value.insert_many(self.cursor.end(self.value), content);

View File

@ -97,23 +97,25 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Error::InvalidData { byte_count } => { Error::InvalidData { byte_count } => {
write!(f, write!(
"The provided RGBA data (with length {:?}) isn't divisble by \ f,
"The provided RGBA data (with length {:?}) isn't divisble by \
4. Therefore, it cannot be safely interpreted as 32bpp RGBA \ 4. Therefore, it cannot be safely interpreted as 32bpp RGBA \
pixels.", pixels.",
byte_count, byte_count,
) )
} }
Error::DimensionsMismatch { Error::DimensionsMismatch {
width, width,
height, height,
pixel_count, pixel_count,
} => { } => {
write!(f, write!(
"The number of RGBA pixels ({:?}) does not match the provided \ f,
"The number of RGBA pixels ({:?}) does not match the provided \
dimensions ({:?}x{:?}).", dimensions ({:?}x{:?}).",
pixel_count, width, height, pixel_count, width, height,
) )
} }
Error::OsError(e) => write!( Error::OsError(e) => write!(
f, f,

View File

@ -134,11 +134,14 @@ impl Pipeline {
bind_group_layouts: &[&constant_layout, &texture_layout], bind_group_layouts: &[&constant_layout, &texture_layout],
}); });
let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor { let shader =
label: Some("iced_wgpu::image::shader"), device.create_shader_module(&wgpu::ShaderModuleDescriptor {
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader/image.wgsl"))), label: Some("iced_wgpu::image::shader"),
flags: wgpu::ShaderFlags::all() source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(
}); include_str!("shader/image.wgsl"),
)),
flags: wgpu::ShaderFlags::all(),
});
let pipeline = let pipeline =
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
@ -422,16 +425,14 @@ impl Pipeline {
let mut render_pass = let mut render_pass =
encoder.begin_render_pass(&wgpu::RenderPassDescriptor { encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("iced_wgpu::image render pass"), label: Some("iced_wgpu::image render pass"),
color_attachments: &[ color_attachments: &[wgpu::RenderPassColorAttachment {
wgpu::RenderPassColorAttachment { view: target,
view: target, resolve_target: None,
resolve_target: None, ops: wgpu::Operations {
ops: wgpu::Operations { load: wgpu::LoadOp::Load,
load: wgpu::LoadOp::Load, store: true,
store: true,
},
}, },
], }],
depth_stencil_attachment: None, depth_stencil_attachment: None,
}); });

View File

@ -119,5 +119,5 @@ fn fs_main(
input.border_radius + 0.5, input.border_radius + 0.5,
dist); dist);
return vec4<f32>(radius_alpha, radius_alpha, radius_alpha, radius_alpha); return vec4<f32>(mixed_color.x, mixed_color.y, mixed_color.z, mixed_color.w * radius_alpha);
} }

View File

@ -74,11 +74,14 @@ impl Blit {
bind_group_layouts: &[&constant_layout, &texture_layout], bind_group_layouts: &[&constant_layout, &texture_layout],
}); });
let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor { let shader =
label: Some("iced_wgpu::triangle::blit_shader"), device.create_shader_module(&wgpu::ShaderModuleDescriptor {
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("../shader/blit.wgsl"))), label: Some("iced_wgpu::triangle::blit_shader"),
flags: wgpu::ShaderFlags::all() source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(
}); include_str!("../shader/blit.wgsl"),
)),
flags: wgpu::ShaderFlags::all(),
});
let pipeline = let pipeline =
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
@ -176,16 +179,14 @@ impl Blit {
let mut render_pass = let mut render_pass =
encoder.begin_render_pass(&wgpu::RenderPassDescriptor { encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("iced_wgpu::triangle::msaa render pass"), label: Some("iced_wgpu::triangle::msaa render pass"),
color_attachments: &[ color_attachments: &[wgpu::RenderPassColorAttachment {
wgpu::RenderPassColorAttachment { view: target,
view: target, resolve_target: None,
resolve_target: None, ops: wgpu::Operations {
ops: wgpu::Operations { load: wgpu::LoadOp::Load,
load: wgpu::LoadOp::Load, store: true,
store: true,
},
}, },
], }],
depth_stencil_attachment: None, depth_stencil_attachment: None,
}); });