Fix all clippy lint errors
This commit is contained in:
parent
d0dcc0e42f
commit
5b3cbb30fc
|
|
@ -3,6 +3,7 @@
|
|||
"matklad.rust-analyzer",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"octref.vetur",
|
||||
"formulahendry.auto-close-tag"
|
||||
"formulahendry.auto-close-tag",
|
||||
"aaron-bond.better-comments"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
// #[test]
|
||||
// fn it_works() {
|
||||
// assert_eq!(2 + 2, 4);
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ pub use crate::tool::ToolMessageHandler;
|
|||
use crate::global::GlobalMessageHandler;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Dispatcher {
|
||||
input_preprocessor: InputPreprocessor,
|
||||
input_mapper: InputMapper,
|
||||
|
|
@ -30,6 +31,10 @@ const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
|
|||
];
|
||||
|
||||
impl Dispatcher {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn handle_message<T: Into<Message>>(&mut self, message: T) {
|
||||
self.messages.push_back(message.into());
|
||||
|
||||
|
|
@ -68,18 +73,6 @@ impl Dispatcher {
|
|||
list
|
||||
}
|
||||
|
||||
pub fn new() -> Dispatcher {
|
||||
Dispatcher {
|
||||
input_preprocessor: InputPreprocessor::default(),
|
||||
global_message_handler: GlobalMessageHandler::new(),
|
||||
input_mapper: InputMapper::default(),
|
||||
documents_message_handler: DocumentsMessageHandler::default(),
|
||||
tool_message_handler: ToolMessageHandler::default(),
|
||||
messages: VecDeque::new(),
|
||||
responses: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
fn log_message(&self, message: &Message) {
|
||||
use Message::*;
|
||||
if log::max_level() == log::LevelFilter::Trace
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use super::document_message_handler::CopyBufferEntry;
|
||||
pub use super::layer_panel::*;
|
||||
use super::movement_handler::{MovementMessage, MovementMessageHandler};
|
||||
use super::overlay_message_handler::OverlayMessageHandler;
|
||||
|
|
@ -187,7 +186,7 @@ impl DocumentMessageHandler {
|
|||
}
|
||||
|
||||
pub fn deserialize_document(serialized_content: &str) -> Result<Self, DocumentError> {
|
||||
log::info!("Deserialising: {:?}", serialized_content);
|
||||
log::info!("Deserializing: {:?}", serialized_content);
|
||||
serde_json::from_str(serialized_content).map_err(|e| DocumentError::InvalidFile(e.to_string()))
|
||||
}
|
||||
|
||||
|
|
@ -210,8 +209,8 @@ impl DocumentMessageHandler {
|
|||
|
||||
pub fn is_unmodified_default(&self) -> bool {
|
||||
self.serialize_root().len() == Self::default().serialize_root().len()
|
||||
&& self.document_undo_history.len() == 0
|
||||
&& self.document_redo_history.len() == 0
|
||||
&& self.document_undo_history.is_empty()
|
||||
&& self.document_redo_history.is_empty()
|
||||
&& self.name.starts_with(DEFAULT_DOCUMENT_NAME)
|
||||
}
|
||||
|
||||
|
|
@ -437,7 +436,7 @@ impl DocumentMessageHandler {
|
|||
Some((document, layer_data)) => {
|
||||
let document = std::mem::replace(&mut self.graphene_document, document);
|
||||
let layer_data = std::mem::replace(&mut self.layer_data, layer_data);
|
||||
self.document_undo_history.push((document.clone(), layer_data.clone()));
|
||||
self.document_undo_history.push((document, layer_data));
|
||||
Ok(())
|
||||
}
|
||||
None => Err(EditorError::NoTransactionInProgress),
|
||||
|
|
@ -645,7 +644,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
|
|||
// Fill the selection range
|
||||
self.layer_data
|
||||
.iter()
|
||||
.filter(|(target, _)| self.graphene_document.layer_is_between(&target, &selected, &self.layer_range_selection_reference))
|
||||
.filter(|(target, _)| self.graphene_document.layer_is_between(target, &selected, &self.layer_range_selection_reference))
|
||||
.for_each(|(layer_path, _)| {
|
||||
paths.push(layer_path.clone());
|
||||
});
|
||||
|
|
@ -664,7 +663,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
|
|||
}
|
||||
|
||||
// Don't create messages for empty operations
|
||||
if paths.len() > 0 {
|
||||
if !paths.is_empty() {
|
||||
// Add or set our selected layers
|
||||
if ctrl {
|
||||
responses.push_front(AddSelectedLayers(paths).into());
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
|
|||
.document_ids
|
||||
.iter()
|
||||
.filter_map(|id| {
|
||||
self.documents.get(&id).map(|doc| FrontendDocumentDetails {
|
||||
self.documents.get(id).map(|doc| FrontendDocumentDetails {
|
||||
is_saved: doc.is_saved(),
|
||||
id: *id,
|
||||
name: doc.name.clone(),
|
||||
|
|
@ -314,7 +314,7 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
|
|||
.document_ids
|
||||
.iter()
|
||||
.filter_map(|id| {
|
||||
self.documents.get(&id).map(|doc| FrontendDocumentDetails {
|
||||
self.documents.get(id).map(|doc| FrontendDocumentDetails {
|
||||
is_saved: doc.is_saved(),
|
||||
id: *id,
|
||||
name: doc.name.clone(),
|
||||
|
|
@ -356,7 +356,7 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
|
|||
self.copy_buffer[clipboard as usize].clear();
|
||||
for path in paths {
|
||||
let document = self.active_document();
|
||||
match (document.graphene_document.layer(&path).map(|t| t.clone()), document.layer_data(&path).clone()) {
|
||||
match (document.graphene_document.layer(&path).map(|t| t.clone()), *document.layer_data(&path)) {
|
||||
(Ok(layer), layer_data) => {
|
||||
self.copy_buffer[clipboard as usize].push(CopyBufferEntry { layer, layer_data });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ pub struct OverlayMessageHandler {
|
|||
}
|
||||
|
||||
impl MessageHandler<OverlayMessage, (&mut LayerData, &Document, &InputPreprocessor)> for OverlayMessageHandler {
|
||||
fn process_action(&mut self, message: OverlayMessage, data: (&mut LayerData, &Document, &InputPreprocessor), responses: &mut VecDeque<Message>) {
|
||||
let (layer_data, document, ipp) = data;
|
||||
fn process_action(&mut self, message: OverlayMessage, _data: (&mut LayerData, &Document, &InputPreprocessor), responses: &mut VecDeque<Message>) {
|
||||
// let (layer_data, document, ipp) = data;
|
||||
use OverlayMessage::*;
|
||||
match message {
|
||||
DispatchOperation(operation) => match self.overlays_graphene_document.handle_operation(&operation) {
|
||||
|
|
|
|||
|
|
@ -13,12 +13,6 @@ pub enum GlobalMessage {
|
|||
#[derive(Debug, Default)]
|
||||
pub struct GlobalMessageHandler {}
|
||||
|
||||
impl GlobalMessageHandler {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl MessageHandler<GlobalMessage, ()> for GlobalMessageHandler {
|
||||
fn process_action(&mut self, message: GlobalMessage, _data: (), _responses: &mut VecDeque<Message>) {
|
||||
use GlobalMessage::*;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ impl ViewportBounds {
|
|||
|
||||
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||
pub struct ScrollDelta {
|
||||
// TODO: Switch these to `f64` values (not trivial because floats don't provide PartialEq, Eq, and Hash)
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub z: i32,
|
||||
|
|
|
|||
|
|
@ -58,13 +58,11 @@ impl SnapHandler {
|
|||
.unwrap_or(0.),
|
||||
);
|
||||
|
||||
// Do not move if over snap tolerance
|
||||
let clamped_closest_move = DVec2::new(
|
||||
// Clamp, do not move if over snap tolerance
|
||||
DVec2::new(
|
||||
if closest_move.x.abs() > SNAP_TOLERANCE { 0. } else { closest_move.x },
|
||||
if closest_move.y.abs() > SNAP_TOLERANCE { 0. } else { closest_move.y },
|
||||
);
|
||||
|
||||
clamped_closest_move
|
||||
)
|
||||
} else {
|
||||
DVec2::ZERO
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ impl Fsm for PathToolFsmState {
|
|||
}
|
||||
}
|
||||
|
||||
fn calculate_total_overlays_per_type(shapes_to_draw: &Vec<VectorManipulatorShape>) -> (usize, usize, usize) {
|
||||
fn calculate_total_overlays_per_type(shapes_to_draw: &[VectorManipulatorShape]) -> (usize, usize, usize) {
|
||||
let (mut total_anchors, mut total_handles, mut total_anchor_handle_lines) = (0, 0, 0);
|
||||
|
||||
for shape_to_draw in shapes_to_draw {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ pub struct JsEditorHandle {
|
|||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
impl JsEditorHandle {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(handle_response: js_sys::Function) -> Self {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use wasm_bindgen_test::*;
|
|||
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn pass() {
|
||||
assert_eq!(1 + 1, 2);
|
||||
}
|
||||
// #[wasm_bindgen_test]
|
||||
// fn pass() {
|
||||
// assert_eq!(1 + 1, 2);
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::color::Color;
|
||||
|
||||
// Document
|
||||
pub const GRAPHENE_DOCUMENT_VERSION: &'static str = "0.0.1";
|
||||
pub const GRAPHENE_DOCUMENT_VERSION: &str = "0.0.1";
|
||||
|
||||
// RENDERING
|
||||
pub const LAYER_OUTLINE_STROKE_COLOR: Color = Color::BLACK;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ impl Document {
|
|||
|
||||
// Determines which layer is closer to the root, if path_a return true, if path_b return false
|
||||
// Answers the question: Is A closer to the root than B?
|
||||
pub fn layer_closer_to_root(&self, path_a: &Vec<u64>, path_b: &Vec<u64>) -> bool {
|
||||
pub fn layer_closer_to_root(&self, path_a: &[u64], path_b: &[u64]) -> bool {
|
||||
// Convert UUIDs to indices
|
||||
let indices_for_path_a = self.indices_for_path(path_a).unwrap();
|
||||
let indices_for_path_b = self.indices_for_path(path_b).unwrap();
|
||||
|
|
@ -126,24 +126,20 @@ impl Document {
|
|||
let index_a = *indices_for_path_a.get(i).unwrap_or(&usize::MAX) as i32;
|
||||
let index_b = *indices_for_path_b.get(i).unwrap_or(&usize::MAX) as i32;
|
||||
|
||||
// index_a == index_b -> true, this means the "2" indices being compared are within the same folder
|
||||
// eg -> [2, X] == [2, X] since we are only comparing the "2" in this iteration
|
||||
// Continue onto comparing the X indices.
|
||||
if index_a == index_b {
|
||||
continue;
|
||||
}
|
||||
|
||||
// At the point at which the two paths first differ, compare to see which is closer to the root
|
||||
if index_a != index_b {
|
||||
// If index_a is smaller, index_a is closer to the root
|
||||
return index_a < index_b;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
false
|
||||
}
|
||||
|
||||
// Is the target layer between a <-> b layers, inclusive
|
||||
pub fn layer_is_between(&self, target: &Vec<u64>, path_a: &Vec<u64>, path_b: &Vec<u64>) -> bool {
|
||||
pub fn layer_is_between(&self, target: &[u64], path_a: &[u64], path_b: &[u64]) -> bool {
|
||||
// If the target is a nonsense path, it isn't between
|
||||
if target.len() < 1 {
|
||||
if target.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -156,8 +152,8 @@ impl Document {
|
|||
let layer_vs_a = self.layer_closer_to_root(target, path_a);
|
||||
let layer_vs_b = self.layer_closer_to_root(target, path_b);
|
||||
|
||||
// To be inbetween you need to be above A and below B or vice versa
|
||||
return layer_vs_a != layer_vs_b;
|
||||
// To be in-between you need to be above A and below B or vice versa
|
||||
layer_vs_a != layer_vs_b
|
||||
}
|
||||
|
||||
/// Given a path to a layer, returns a vector of the indices in the layer tree
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ use syn::parse_macro_input;
|
|||
///
|
||||
/// This derive macro is enum-only.
|
||||
///
|
||||
/// The discriminant enum is a copy of the input enum with all fields of every variant removed.\
|
||||
/// *) The exception to that rule is the `#[child]` attribute
|
||||
/// The discriminant enum is a copy of the input enum with all fields of every variant removed.
|
||||
/// The exception to that rule is the `#[child]` attribute.
|
||||
///
|
||||
/// # Helper attributes
|
||||
/// - `#[sub_discriminant]`: only usable on variants with a single field; instead of no fields, the discriminant of the single field will be included in the discriminant,
|
||||
|
|
@ -252,7 +252,7 @@ pub fn derive_hint(input_item: TokenStream) -> TokenStream {
|
|||
/// SelectToolState::TransformSelected
|
||||
/// }
|
||||
/// (SelectToolState::TransformSelected, Event::MouseMove(x,y)) => {
|
||||
/// #[egde("Mouse Move")]
|
||||
/// #[edge("Mouse Move")]
|
||||
/// SelectToolState::TransformSelected
|
||||
/// }
|
||||
/// (SelectToolState::TransformSelected, Event::MouseUp(mouse_state)) if *mouse_state == MouseState::Left => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue