Fix lints by clippy

This commit is contained in:
Héctor Ramón Jiménez 2022-11-03 04:53:27 +01:00
parent edce457365
commit 7e22e2d452
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
9 changed files with 20 additions and 28 deletions

View file

@ -137,12 +137,12 @@ impl Pipeline {
match mesh.style { match mesh.style {
mesh::Style::Solid(color) => { mesh::Style::Solid(color) => {
self.programs.solid.use_program(gl, &color, &transform); self.programs.solid.use_program(gl, color, &transform);
} }
mesh::Style::Gradient(gradient) => { mesh::Style::Gradient(gradient) => {
self.programs self.programs
.gradient .gradient
.use_program(gl, &gradient, &transform); .use_program(gl, gradient, &transform);
} }
} }

View file

@ -36,12 +36,9 @@ pub enum Position {
}, },
} }
impl Into<Position> for (Point, Point) { impl From<(Point, Point)> for Position {
fn into(self) -> Position { fn from((start, end): (Point, Point)) -> Self {
Position::Absolute { Self::Absolute { start, end }
start: self.0,
end: self.1,
}
} }
} }

View file

@ -28,13 +28,9 @@ pub enum Style {
Gradient(Gradient), Gradient(Gradient),
} }
impl<'a> Into<Style> for Gradient { impl From<Gradient> for Style {
fn into(self) -> Style { fn from(gradient: Gradient) -> Self {
match self { Self::Gradient(gradient)
Gradient::Linear(linear) => {
Style::Gradient(Gradient::Linear(linear))
}
}
} }
} }

View file

@ -52,8 +52,8 @@ impl From<Transformation> for [f32; 16] {
} }
} }
impl Into<Mat4> for Transformation { impl From<Transformation> for Mat4 {
fn into(self) -> Mat4 { fn from(transformation: Transformation) -> Self {
self.0 transformation.0
} }
} }

View file

@ -42,10 +42,10 @@ impl<'a> From<Color> for Fill<'a> {
} }
} }
impl<'a> Into<Fill<'a>> for &'a Gradient { impl<'a> From<&'a Gradient> for Fill<'a> {
fn into(self) -> Fill<'a> { fn from(gradient: &'a Gradient) -> Self {
Fill { Fill {
style: Style::Gradient(self), style: Style::Gradient(gradient),
..Default::default() ..Default::default()
} }
} }

View file

@ -57,8 +57,7 @@ impl<T: Pod + Zeroable> StaticBuffer<T> {
/// Returns whether or not the buffer needs to be recreated. This can happen whenever mesh data /// Returns whether or not the buffer needs to be recreated. This can happen whenever mesh data
/// changes & a redraw is requested. /// changes & a redraw is requested.
pub fn resize(&mut self, device: &wgpu::Device, new_count: usize) -> bool { pub fn resize(&mut self, device: &wgpu::Device, new_count: usize) -> bool {
let size = let size = (mem::size_of::<T>() * new_count) as u64;
wgpu::BufferAddress::from((mem::size_of::<T>() * new_count) as u64);
if self.size < size { if self.size < size {
self.offsets.clear(); self.offsets.clear();

View file

@ -180,8 +180,8 @@ impl<T: ShaderType + WriteInto> Buffer<T> {
let offset = self let offset = self
.offsets .offsets
.get(index) .get(index)
.expect("Index not found in offsets.") .copied()
.clone(); .expect("Index not found in offsets.");
offset offset
} }

View file

@ -134,8 +134,8 @@ impl Pipeline {
&mesh.buffers.indices, &mesh.buffers.indices,
); );
vertex_offset = vertex_offset + new_vertex_offset; vertex_offset += new_vertex_offset;
index_offset = index_offset + new_index_offset; index_offset += new_index_offset;
self.index_strides.push(mesh.buffers.indices.len() as u32); self.index_strides.push(mesh.buffers.indices.len() as u32);

View file

@ -57,7 +57,7 @@ impl Pipeline {
}); });
let bind_group = let bind_group =
Pipeline::bind_group(device, &buffer.raw(), &bind_group_layout); Pipeline::bind_group(device, buffer.raw(), &bind_group_layout);
let layout = let layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {