Remove warnings from build and satisfied clippy (#1288)

* Prefixed unused functions with underscore

* Applied clippy lints

* Fixed some warnings and removed some `allow` statements
This commit is contained in:
Prikshit Gautam
2023-06-07 14:46:47 +05:30
committed by Keavon Chambers
parent 054acd3cc9
commit 70fcb35444
33 changed files with 54 additions and 60 deletions

View File

@@ -53,7 +53,7 @@ impl ApplicationIo for WasmApplicationIo {
let image_canvases_key = JsValue::from_str("imageCanvases");
let mut canvases = Reflect::get(&window, &image_canvases_key);
if let Err(_) = canvases {
if canvases.is_err() {
Reflect::set(&JsValue::from(web_sys::window().unwrap()), &image_canvases_key, &Object::new()).unwrap();
canvases = Reflect::get(&window, &image_canvases_key);
}
@@ -117,11 +117,11 @@ async fn draw_image_frame_node<'a: 'input>(image: ImageFrame<SRGBA8>, surface_ha
let canvas = surface_handle.surface.canvas().expect("Failed to get canvas");
canvas.set_width(image.image.width);
canvas.set_height(image.image.height);
let image_data = web_sys::ImageData::new_with_u8_clamped_array_and_sh(array, image.image.width as u32, image.image.height as u32).expect("Failed to construct ImageData");
let image_data = web_sys::ImageData::new_with_u8_clamped_array_and_sh(array, image.image.width, image.image.height).expect("Failed to construct ImageData");
surface_handle.surface.put_image_data(&image_data, 0.0, 0.0).unwrap();
}
SurfaceHandleFrame {
surface_handle: surface_handle.into(),
surface_handle,
transform: image.transform,
}
}

View File

@@ -1,6 +1,6 @@
#![allow(clippy::too_many_arguments)]
use super::Color;
use crate::Node;
use core::fmt::Debug;
use dyn_any::{DynAny, StaticType};
#[cfg(feature = "serde")]
@@ -195,7 +195,7 @@ fn extract_channel_node(color: Color, channel: RedGreenBlue) -> Color {
RedGreenBlue::Green => color.g(),
RedGreenBlue::Blue => color.b(),
};
return color.map_rgb(|_| extracted_value);
color.map_rgb(|_| extracted_value)
}
#[derive(Debug, Clone, Copy, Default)]

View File

@@ -1,3 +1,4 @@
#![allow(clippy::neg_cmp_op_on_partial_ord)]
//! Fast conversions between u8 sRGB and linear float.
// Inspired by https://gist.github.com/rygorous/2203834, but with a slightly

View File

@@ -13,7 +13,7 @@ mod base64_serde {
use super::super::Pixel;
use serde::{Deserialize, Deserializer, Serializer};
pub fn as_base64<S, P: Pixel>(key: &Vec<P>, serializer: S) -> Result<S::Ok, S::Error>
pub fn as_base64<S, P: Pixel>(key: &[P], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
@@ -27,7 +27,7 @@ mod base64_serde {
{
use serde::de::Error;
let color_from_chunk = |chunk: &[u8]| P::from_bytes(chunk.try_into().unwrap());
let color_from_chunk = |chunk: &[u8]| P::from_bytes(chunk);
let colors_from_bytes = |bytes: Vec<u8>| bytes.chunks_exact(P::byte_size()).map(color_from_chunk).collect();

View File

@@ -26,23 +26,24 @@ impl OutlineBuilder for Builder {
if !self.current_subpath.is_empty() {
self.other_subpaths.push(core::mem::replace(&mut self.current_subpath, Subpath::new(Vec::new(), false)));
}
self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(self.point(x, y), self.id.next()));
self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(self.point(x, y), self.id.next_id()));
}
fn line_to(&mut self, x: f32, y: f32) {
self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(self.point(x, y), self.id.next()));
self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(self.point(x, y), self.id.next_id()));
}
fn quad_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32) {
let [handle, anchor] = [self.point(x1, y1), self.point(x2, y2)];
self.current_subpath.last_manipulator_group_mut().unwrap().out_handle = Some(handle);
self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(anchor, self.id.next()));
self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(anchor, self.id.next_id()));
}
fn curve_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32) {
let [handle1, handle2, anchor] = [self.point(x1, y1), self.point(x2, y2), self.point(x3, y3)];
self.current_subpath.last_manipulator_group_mut().unwrap().out_handle = Some(handle1);
self.current_subpath.push_manipulator_group(ManipulatorGroup::new_with_id(anchor, Some(handle2), None, self.id.next()));
self.current_subpath
.push_manipulator_group(ManipulatorGroup::new_with_id(anchor, Some(handle2), None, self.id.next_id()));
}
fn close(&mut self) {

View File

@@ -84,7 +84,7 @@ impl bezier_rs::Identifier for ManipulatorGroupId {
impl ManipulatorGroupId {
pub const ZERO: ManipulatorGroupId = ManipulatorGroupId(0);
pub fn next(&mut self) -> Self {
pub fn next_id(&mut self) -> Self {
let old = self.0;
self.0 += 1;
Self(old)

View File

@@ -115,8 +115,8 @@ impl<'i, T: Clone + 'i> Node<'i, ()> for DebugClonedNode<T> {
}
impl<T: Clone> DebugClonedNode<T> {
pub const fn new(value: T) -> ClonedNode<T> {
ClonedNode(value)
pub const fn new(value: T) -> DebugClonedNode<T> {
DebugClonedNode(value)
}
}