From 5b3cbb30fcd97b1680f4ce4ea77037b35a928c02 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Thu, 30 Dec 2021 23:05:54 -0800 Subject: [PATCH] Fix all clippy lint errors --- .vscode/extensions.json | 5 +- charcoal/src/lib.rs | 8 +- editor/src/communication/dispatcher.rs | 17 +- editor/src/document/document_file.rs | 13 +- .../src/document/document_message_handler.rs | 6 +- .../src/document/overlay_message_handler.rs | 4 +- editor/src/global/global_message_handler.rs | 6 - editor/src/input/keyboard.rs | 2 +- editor/src/input/mouse.rs | 1 + editor/src/tool/snapping.rs | 8 +- editor/src/tool/tools/line.rs | 2 +- editor/src/tool/tools/path.rs | 2 +- .../scrollbars/PersistentScrollbar.vue | 2 +- frontend/wasm/src/api.rs | 1 + frontend/wasm/tests/web.rs | 8 +- graphene/src/consts.rs | 2 +- graphene/src/document.rs | 26 ++- proc-macros/src/lib.rs | 150 +++++++++--------- 18 files changed, 123 insertions(+), 140 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 13a358fb..4ca60637 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,6 +3,7 @@ "matklad.rust-analyzer", "dbaeumer.vscode-eslint", "octref.vetur", - "formulahendry.auto-close-tag" + "formulahendry.auto-close-tag", + "aaron-bond.better-comments" ] -} \ No newline at end of file +} diff --git a/charcoal/src/lib.rs b/charcoal/src/lib.rs index 909562f6..78b81e00 100644 --- a/charcoal/src/lib.rs +++ b/charcoal/src/lib.rs @@ -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); + // } } diff --git a/editor/src/communication/dispatcher.rs b/editor/src/communication/dispatcher.rs index abe519d9..cc7331f6 100644 --- a/editor/src/communication/dispatcher.rs +++ b/editor/src/communication/dispatcher.rs @@ -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>(&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 diff --git a/editor/src/document/document_file.rs b/editor/src/document/document_file.rs index 8d3eb01e..9c3789e0 100644 --- a/editor/src/document/document_file.rs +++ b/editor/src/document/document_file.rs @@ -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 { - 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 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 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()); diff --git a/editor/src/document/document_message_handler.rs b/editor/src/document/document_message_handler.rs index 159cb06d..fe160a61 100644 --- a/editor/src/document/document_message_handler.rs +++ b/editor/src/document/document_message_handler.rs @@ -249,7 +249,7 @@ impl MessageHandler 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 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 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 }); } diff --git a/editor/src/document/overlay_message_handler.rs b/editor/src/document/overlay_message_handler.rs index 6bd3dbae..9088d9a0 100644 --- a/editor/src/document/overlay_message_handler.rs +++ b/editor/src/document/overlay_message_handler.rs @@ -30,8 +30,8 @@ pub struct OverlayMessageHandler { } impl MessageHandler for OverlayMessageHandler { - fn process_action(&mut self, message: OverlayMessage, data: (&mut LayerData, &Document, &InputPreprocessor), responses: &mut VecDeque) { - let (layer_data, document, ipp) = data; + fn process_action(&mut self, message: OverlayMessage, _data: (&mut LayerData, &Document, &InputPreprocessor), responses: &mut VecDeque) { + // let (layer_data, document, ipp) = data; use OverlayMessage::*; match message { DispatchOperation(operation) => match self.overlays_graphene_document.handle_operation(&operation) { diff --git a/editor/src/global/global_message_handler.rs b/editor/src/global/global_message_handler.rs index f447a43e..6fe1fb1e 100644 --- a/editor/src/global/global_message_handler.rs +++ b/editor/src/global/global_message_handler.rs @@ -13,12 +13,6 @@ pub enum GlobalMessage { #[derive(Debug, Default)] pub struct GlobalMessageHandler {} -impl GlobalMessageHandler { - pub fn new() -> Self { - Self::default() - } -} - impl MessageHandler for GlobalMessageHandler { fn process_action(&mut self, message: GlobalMessage, _data: (), _responses: &mut VecDeque) { use GlobalMessage::*; diff --git a/editor/src/input/keyboard.rs b/editor/src/input/keyboard.rs index f0ec9b99..3198b8cd 100644 --- a/editor/src/input/keyboard.rs +++ b/editor/src/input/keyboard.rs @@ -197,7 +197,7 @@ macro_rules! bit_ops { macro_rules! bit_ops_assign { ($(($op:ident, $func:ident)),* $(,)?) => { $(impl $op for BitVector { - fn $func(&mut self, right: Self) { + fn $func(&mut self, right: Self) { for (left, right) in self.0.iter_mut().zip(right.0.iter()) { $op::$func(left, right); } diff --git a/editor/src/input/mouse.rs b/editor/src/input/mouse.rs index ca1d514b..023a9a35 100644 --- a/editor/src/input/mouse.rs +++ b/editor/src/input/mouse.rs @@ -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, diff --git a/editor/src/tool/snapping.rs b/editor/src/tool/snapping.rs index 3f4792fa..1597361b 100644 --- a/editor/src/tool/snapping.rs +++ b/editor/src/tool/snapping.rs @@ -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 } diff --git a/editor/src/tool/tools/line.rs b/editor/src/tool/tools/line.rs index 8053ce19..c348a8d6 100644 --- a/editor/src/tool/tools/line.rs +++ b/editor/src/tool/tools/line.rs @@ -42,7 +42,7 @@ impl<'a> MessageHandler> for Line { fn actions(&self) -> ActionList { use LineToolFsmState::*; match self.fsm_state { - Ready => actions!(LineMessageDiscriminant; DragStart), + Ready => actions!(LineMessageDiscriminant; DragStart), Drawing => actions!(LineMessageDiscriminant; DragStop, Redraw, Abort), } } diff --git a/editor/src/tool/tools/path.rs b/editor/src/tool/tools/path.rs index 24fafc22..713acb53 100644 --- a/editor/src/tool/tools/path.rs +++ b/editor/src/tool/tools/path.rs @@ -303,7 +303,7 @@ impl Fsm for PathToolFsmState { } } -fn calculate_total_overlays_per_type(shapes_to_draw: &Vec) -> (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 { diff --git a/frontend/src/components/widgets/scrollbars/PersistentScrollbar.vue b/frontend/src/components/widgets/scrollbars/PersistentScrollbar.vue index 617d58f0..6b3d89e6 100644 --- a/frontend/src/components/widgets/scrollbars/PersistentScrollbar.vue +++ b/frontend/src/components/widgets/scrollbars/PersistentScrollbar.vue @@ -114,7 +114,7 @@ import { defineComponent, PropType } from "vue"; const lerp = (x: number, y: number, a: number) => x * (1 - a) + y * a; // Convert the position of the handle (0-1) to the position on the track (0-1). -// This includes the 1/2 handle length gap of the possible handle positionson each side so the end of the handle doesn't go off the track. +// This includes the 1/2 handle length gap of the possible handle positionson each side so the end of the handle doesn't go off the track. const handleToTrack = (handleLen: number, handlePos: number) => lerp(handleLen / 2, 1 - handleLen / 2, handlePos); const pointerPosition = (direction: ScrollbarDirection, e: PointerEvent) => (direction === ScrollbarDirection.Vertical ? e.clientY : e.clientX); diff --git a/frontend/wasm/src/api.rs b/frontend/wasm/src/api.rs index e4c49a40..fd4b0be7 100644 --- a/frontend/wasm/src/api.rs +++ b/frontend/wasm/src/api.rs @@ -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 { diff --git a/frontend/wasm/tests/web.rs b/frontend/wasm/tests/web.rs index db945dfd..b8e2cd50 100644 --- a/frontend/wasm/tests/web.rs +++ b/frontend/wasm/tests/web.rs @@ -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); +// } diff --git a/graphene/src/consts.rs b/graphene/src/consts.rs index a89da61c..ed30f48d 100644 --- a/graphene/src/consts.rs +++ b/graphene/src/consts.rs @@ -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; diff --git a/graphene/src/document.rs b/graphene/src/document.rs index 90c4517f..002a72c5 100644 --- a/graphene/src/document.rs +++ b/graphene/src/document.rs @@ -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, path_b: &Vec) -> 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; } - - // 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, path_a: &Vec, path_b: &Vec) -> bool { + // Is the target layer between a <-> b layers, inclusive + 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 diff --git a/proc-macros/src/lib.rs b/proc-macros/src/lib.rs index 7b99851a..5067a74d 100644 --- a/proc-macros/src/lib.rs +++ b/proc-macros/src/lib.rs @@ -19,12 +19,12 @@ 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, -/// acting as a sub-discriminant. +/// acting as a sub-discriminant. /// - `#[discriminant_attr(…)]`: usable on the enum itself or on any variant; applies `#[…]` in its place on the discriminant. /// /// # Attributes on the Discriminant @@ -40,20 +40,20 @@ use syn::parse_macro_input; /// #[derive(ToDiscriminant)] /// #[discriminant_attr(derive(Debug, Eq, PartialEq))] /// pub enum EnumA { -/// A(u8), -/// #[sub_discriminant] -/// B(EnumB) +/// A(u8), +/// #[sub_discriminant] +/// B(EnumB) /// } /// /// #[derive(ToDiscriminant)] /// #[discriminant_attr(derive(Debug, Eq, PartialEq))] /// #[discriminant_attr(repr(u8))] /// pub enum EnumB { -/// Foo(u8), -/// Bar(String), -/// #[cfg(feature = "some-feature")] -/// #[discriminant_attr(cfg(feature = "some-feature"))] -/// WindowsBar(OsString) +/// Foo(u8), +/// Bar(String), +/// #[cfg(feature = "some-feature")] +/// #[discriminant_attr(cfg(feature = "some-feature"))] +/// WindowsBar(OsString) /// } /// /// let a = EnumA::A(1); @@ -73,7 +73,7 @@ pub fn derive_discriminant(input_item: TokenStream) -> TokenStream { /// /// # Helper Attributes /// - `#[parent(, )]` (**required**): declare the parent type (``) -/// and a function (``, has to evaluate to a single arg function) for converting a value of this type to the parent type +/// and a function (``, has to evaluate to a single arg function) for converting a value of this type to the parent type /// - `#[parent_is_top]`: Denote that the parent type has no further parent type (this is required because otherwise the `From` impls for parent and top parent would overlap) /// /// # Example @@ -85,23 +85,23 @@ pub fn derive_discriminant(input_item: TokenStream) -> TokenStream { /// struct A { u: u8, b: B }; /// /// impl A { -/// pub fn from_b(b: B) -> Self { -/// Self { u: 7, b } -/// } +/// pub fn from_b(b: B) -> Self { +/// Self { u: 7, b } +/// } /// } /// /// impl TransitiveChild for A { -/// type Parent = Self; -/// type TopParent = Self; +/// type Parent = Self; +/// type TopParent = Self; /// } /// /// #[derive(TransitiveChild, Debug, Eq, PartialEq)] /// #[parent(A, A::from_b)] /// #[parent_is_top] /// enum B { -/// Foo, -/// Bar, -/// Child(C) +/// Foo, +/// Bar, +/// Child(C) /// } /// /// #[derive(TransitiveChild, Debug, Eq, PartialEq)] @@ -134,41 +134,41 @@ pub fn derive_transitive_child(input_item: TokenStream) -> TokenStream { /// /// #[derive(AsMessage)] /// pub enum TopMessage { -/// A(u8), -/// B(u16), -/// #[child] -/// C(MessageC), -/// #[child] -/// D(MessageD) +/// A(u8), +/// B(u16), +/// #[child] +/// C(MessageC), +/// #[child] +/// D(MessageD) /// } /// /// impl TransitiveChild for TopMessage { -/// type Parent = Self; -/// type TopParent = Self; +/// type Parent = Self; +/// type TopParent = Self; /// } /// /// #[derive(TransitiveChild, AsMessage, Copy, Clone)] /// #[parent(TopMessage, TopMessage::C)] /// #[parent_is_top] /// pub enum MessageC { -/// X1, -/// X2 +/// X1, +/// X2 /// } /// /// #[derive(TransitiveChild, AsMessage, Copy, Clone)] /// #[parent(TopMessage, TopMessage::D)] /// #[parent_is_top] /// pub enum MessageD { -/// Y1, -/// #[child] -/// Y2(MessageE) +/// Y1, +/// #[child] +/// Y2(MessageE) /// } /// /// #[derive(TransitiveChild, AsMessage, Copy, Clone)] /// #[parent(MessageD, MessageD::Y2)] /// pub enum MessageE { -/// Alpha, -/// Beta +/// Alpha, +/// Beta /// } /// /// let c = MessageC::X1; @@ -195,18 +195,18 @@ pub fn derive_message(input_item: TokenStream) -> TokenStream { /// # Usage /// There are three possible argument syntaxes you can use: /// 1. no arguments: this is for the top-level message enum. It derives `ToDiscriminant`, `AsMessage` on the discriminant, and implements `TransitiveChild` on both -/// (the parent and top parent being the respective types themselves). -/// It also derives the following `std` traits on the discriminant: `Debug, Copy, Clone, PartialEq, Eq, Hash`. +/// (the parent and top parent being the respective types themselves). +/// It also derives the following `std` traits on the discriminant: `Debug, Copy, Clone, PartialEq, Eq, Hash`. /// 2. two arguments: this is for message enums whose direct parent is the top level message enum. The syntax is `#[impl_message(, )]`, -/// where `` is the parent message type and `` is the identifier of the variant used to construct this child. -/// It derives `ToDiscriminant`, `AsMessage` on the discriminant, and `TransitiveChild` on both (adding `#[parent_is_top]` to both). -/// It also derives the following `std` traits on the discriminant: `Debug, Copy, Clone, PartialEq, Eq, Hash`. +/// where `` is the parent message type and `` is the identifier of the variant used to construct this child. +/// It derives `ToDiscriminant`, `AsMessage` on the discriminant, and `TransitiveChild` on both (adding `#[parent_is_top]` to both). +/// It also derives the following `std` traits on the discriminant: `Debug, Copy, Clone, PartialEq, Eq, Hash`. /// 3. three arguments: this is for all other message enums that are transitive children of the top level message enum. The syntax is -/// `#[impl_message(, , )]`, where the first `` is the top parent message type, the second `` is the parent message type -/// and `` is the identifier of the variant used to construct this child. -/// It derives `ToDiscriminant`, `AsMessage` on the discriminant, and `TransitiveChild` on both. -/// It also derives the following `std` traits on the discriminant: `Debug, Copy, Clone, PartialEq, Eq, Hash`. -/// **This third option will likely change in the future** +/// `#[impl_message(, , )]`, where the first `` is the top parent message type, the second `` is the parent message type +/// and `` is the identifier of the variant used to construct this child. +/// It derives `ToDiscriminant`, `AsMessage` on the discriminant, and `TransitiveChild` on both. +/// It also derives the following `std` traits on the discriminant: `Debug, Copy, Clone, PartialEq, Eq, Hash`. +/// **This third option will likely change in the future** #[proc_macro_attribute] pub fn impl_message(attr: TokenStream, input_item: TokenStream) -> TokenStream { TokenStream::from(combined_message_attrs_impl(attr.into(), input_item.into()).unwrap_or_else(|err| err.to_compile_error())) @@ -221,12 +221,12 @@ pub fn impl_message(attr: TokenStream, input_item: TokenStream) -> TokenStream { /// /// #[derive(Hint)] /// pub enum StateMachine { -/// #[hint(rmb = "foo", lmb = "bar")] -/// Ready, -/// #[hint(alt = "baz")] -/// RMBDown, -/// // no hint (also ok) -/// LMBDown +/// #[hint(rmb = "foo", lmb = "bar")] +/// Ready, +/// #[hint(alt = "baz")] +/// RMBDown, +/// // no hint (also ok) +/// LMBDown /// } /// ``` #[proc_macro_derive(Hint, attributes(hint))] @@ -239,30 +239,30 @@ pub fn derive_hint(input_item: TokenStream) -> TokenStream { /// # Example /// ```ignore /// match (example_tool_state, event) { -/// (ToolState::Ready, Event::MouseDown(mouse_state)) if *mouse_state == MouseState::Left => { -/// #[edge("LMB Down")] -/// ToolState::Pending -/// } -/// (SelectToolState::Pending, Event::MouseUp(mouse_state)) if *mouse_state == MouseState::Left => { -/// #[edge("LMB Up: Select Object")] -/// SelectToolState::Ready -/// } -/// (SelectToolState::Pending, Event::MouseMove(x,y)) => { -/// #[edge("Mouse Move")] -/// SelectToolState::TransformSelected -/// } -/// (SelectToolState::TransformSelected, Event::MouseMove(x,y)) => { -/// #[egde("Mouse Move")] -/// SelectToolState::TransformSelected -/// } -/// (SelectToolState::TransformSelected, Event::MouseUp(mouse_state)) if *mouse_state == MouseState::Left => { -/// #[edge("LMB Up")] -/// SelectToolState::Ready -/// } -/// (state, _) => { -/// // Do nothing -/// state -/// } +/// (ToolState::Ready, Event::MouseDown(mouse_state)) if *mouse_state == MouseState::Left => { +/// #[edge("LMB Down")] +/// ToolState::Pending +/// } +/// (SelectToolState::Pending, Event::MouseUp(mouse_state)) if *mouse_state == MouseState::Left => { +/// #[edge("LMB Up: Select Object")] +/// SelectToolState::Ready +/// } +/// (SelectToolState::Pending, Event::MouseMove(x,y)) => { +/// #[edge("Mouse Move")] +/// SelectToolState::TransformSelected +/// } +/// (SelectToolState::TransformSelected, Event::MouseMove(x,y)) => { +/// #[edge("Mouse Move")] +/// SelectToolState::TransformSelected +/// } +/// (SelectToolState::TransformSelected, Event::MouseUp(mouse_state)) if *mouse_state == MouseState::Left => { +/// #[edge("LMB Up")] +/// SelectToolState::Ready +/// } +/// (state, _) => { +/// // Do nothing +/// state +/// } /// } /// ``` #[proc_macro_attribute]