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> {
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"))]
{

View File

@ -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,
}

View File

@ -78,7 +78,8 @@ where
.drain(..)
.map(|recipe| {
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(),
}

View File

@ -209,10 +209,11 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
) {
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 {

View File

@ -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)
}
_ => (),
_ => {}
}
}

View File

@ -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);

View File

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

View File

@ -134,10 +134,13 @@ impl Pipeline {
bind_group_layouts: &[&constant_layout, &texture_layout],
});
let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor {
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()
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(
include_str!("shader/image.wgsl"),
)),
flags: wgpu::ShaderFlags::all(),
});
let pipeline =
@ -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 {
color_attachments: &[wgpu::RenderPassColorAttachment {
view: target,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Load,
store: true,
},
},
],
}],
depth_stencil_attachment: None,
});

View File

@ -119,5 +119,5 @@ fn fs_main(
input.border_radius + 0.5,
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,10 +74,13 @@ impl Blit {
bind_group_layouts: &[&constant_layout, &texture_layout],
});
let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor {
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()
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(
include_str!("../shader/blit.wgsl"),
)),
flags: wgpu::ShaderFlags::all(),
});
let pipeline =
@ -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 {
color_attachments: &[wgpu::RenderPassColorAttachment {
view: target,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Load,
store: true,
},
},
],
}],
depth_stencil_attachment: None,
});