Fix inconsistent whitespace

This commit is contained in:
Keavon Chambers 2021-07-23 17:48:39 -07:00
parent f5376599e9
commit c663b160e6
4 changed files with 81 additions and 76 deletions

View File

@ -1,3 +1,8 @@
{ {
"recommendations": ["matklad.rust-analyzer", "dbaeumer.vscode-eslint", "octref.vetur", "formulahendry.auto-close-tag"] "recommendations": [
"matklad.rust-analyzer",
"dbaeumer.vscode-eslint",
"octref.vetur",
"formulahendry.auto-close-tag"
]
} }

View File

@ -54,4 +54,4 @@
"git add" "git add"
] ]
} }
} }

View File

@ -76,7 +76,7 @@ macro_rules! gen_tools_hash_map {
/// }; /// };
/// ``` /// ```
macro_rules! match_variant_name { macro_rules! match_variant_name {
(match ($e:expr) { $($v:ident),* $(,)? }) => { (match ($e:expr) { $($v:ident),* $(,)? }) => {
match $e { match $e {
$( $(
$v { .. } => stringify!($v) $v { .. } => stringify!($v)

View File

@ -24,7 +24,7 @@ use syn::parse_macro_input;
/// ///
/// # Helper attributes /// # 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, /// - `#[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. /// - `#[discriminant_attr(…)]`: usable on the enum itself or on any variant; applies `#[…]` in its place on the discriminant.
/// ///
/// # Attributes on the Discriminant /// # Attributes on the Discriminant
@ -40,20 +40,20 @@ use syn::parse_macro_input;
/// #[derive(ToDiscriminant)] /// #[derive(ToDiscriminant)]
/// #[discriminant_attr(derive(Debug, Eq, PartialEq))] /// #[discriminant_attr(derive(Debug, Eq, PartialEq))]
/// pub enum EnumA { /// pub enum EnumA {
/// A(u8), /// A(u8),
/// #[sub_discriminant] /// #[sub_discriminant]
/// B(EnumB) /// B(EnumB)
/// } /// }
/// ///
/// #[derive(ToDiscriminant)] /// #[derive(ToDiscriminant)]
/// #[discriminant_attr(derive(Debug, Eq, PartialEq))] /// #[discriminant_attr(derive(Debug, Eq, PartialEq))]
/// #[discriminant_attr(repr(u8))] /// #[discriminant_attr(repr(u8))]
/// pub enum EnumB { /// pub enum EnumB {
/// Foo(u8), /// Foo(u8),
/// Bar(String), /// Bar(String),
/// #[cfg(feature = "some-feature")] /// #[cfg(feature = "some-feature")]
/// #[discriminant_attr(cfg(feature = "some-feature"))] /// #[discriminant_attr(cfg(feature = "some-feature"))]
/// WindowsBar(OsString) /// WindowsBar(OsString)
/// } /// }
/// ///
/// let a = EnumA::A(1); /// let a = EnumA::A(1);
@ -73,7 +73,7 @@ pub fn derive_discriminant(input_item: TokenStream) -> TokenStream {
/// ///
/// # Helper Attributes /// # Helper Attributes
/// - `#[parent(<Type>, <Expr>)]` (**required**): declare the parent type (`<Type>`) /// - `#[parent(<Type>, <Expr>)]` (**required**): declare the parent type (`<Type>`)
/// and a function (`<Expr>`, has to evaluate to a single arg function) for converting a value of this type to the parent type /// and a function (`<Expr>`, 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) /// - `#[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 /// # Example
@ -85,23 +85,23 @@ pub fn derive_discriminant(input_item: TokenStream) -> TokenStream {
/// struct A { u: u8, b: B }; /// struct A { u: u8, b: B };
/// ///
/// impl A { /// impl A {
/// pub fn from_b(b: B) -> Self { /// pub fn from_b(b: B) -> Self {
/// Self { u: 7, b } /// Self { u: 7, b }
/// } /// }
/// } /// }
/// ///
/// impl TransitiveChild for A { /// impl TransitiveChild for A {
/// type Parent = Self; /// type Parent = Self;
/// type TopParent = Self; /// type TopParent = Self;
/// } /// }
/// ///
/// #[derive(TransitiveChild, Debug, Eq, PartialEq)] /// #[derive(TransitiveChild, Debug, Eq, PartialEq)]
/// #[parent(A, A::from_b)] /// #[parent(A, A::from_b)]
/// #[parent_is_top] /// #[parent_is_top]
/// enum B { /// enum B {
/// Foo, /// Foo,
/// Bar, /// Bar,
/// Child(C) /// Child(C)
/// } /// }
/// ///
/// #[derive(TransitiveChild, Debug, Eq, PartialEq)] /// #[derive(TransitiveChild, Debug, Eq, PartialEq)]
@ -134,41 +134,41 @@ pub fn derive_transitive_child(input_item: TokenStream) -> TokenStream {
/// ///
/// #[derive(AsMessage)] /// #[derive(AsMessage)]
/// pub enum TopMessage { /// pub enum TopMessage {
/// A(u8), /// A(u8),
/// B(u16), /// B(u16),
/// #[child] /// #[child]
/// C(MessageC), /// C(MessageC),
/// #[child] /// #[child]
/// D(MessageD) /// D(MessageD)
/// } /// }
/// ///
/// impl TransitiveChild for TopMessage { /// impl TransitiveChild for TopMessage {
/// type Parent = Self; /// type Parent = Self;
/// type TopParent = Self; /// type TopParent = Self;
/// } /// }
/// ///
/// #[derive(TransitiveChild, AsMessage, Copy, Clone)] /// #[derive(TransitiveChild, AsMessage, Copy, Clone)]
/// #[parent(TopMessage, TopMessage::C)] /// #[parent(TopMessage, TopMessage::C)]
/// #[parent_is_top] /// #[parent_is_top]
/// pub enum MessageC { /// pub enum MessageC {
/// X1, /// X1,
/// X2 /// X2
/// } /// }
/// ///
/// #[derive(TransitiveChild, AsMessage, Copy, Clone)] /// #[derive(TransitiveChild, AsMessage, Copy, Clone)]
/// #[parent(TopMessage, TopMessage::D)] /// #[parent(TopMessage, TopMessage::D)]
/// #[parent_is_top] /// #[parent_is_top]
/// pub enum MessageD { /// pub enum MessageD {
/// Y1, /// Y1,
/// #[child] /// #[child]
/// Y2(MessageE) /// Y2(MessageE)
/// } /// }
/// ///
/// #[derive(TransitiveChild, AsMessage, Copy, Clone)] /// #[derive(TransitiveChild, AsMessage, Copy, Clone)]
/// #[parent(MessageD, MessageD::Y2)] /// #[parent(MessageD, MessageD::Y2)]
/// pub enum MessageE { /// pub enum MessageE {
/// Alpha, /// Alpha,
/// Beta /// Beta
/// } /// }
/// ///
/// let c = MessageC::X1; /// let c = MessageC::X1;
@ -195,18 +195,18 @@ pub fn derive_message(input_item: TokenStream) -> TokenStream {
/// # Usage /// # Usage
/// There are three possible argument syntaxes you can use: /// 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 /// 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). /// (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`. /// 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(<Type>, <Ident>)]`, /// 2. two arguments: this is for message enums whose direct parent is the top level message enum. The syntax is `#[impl_message(<Type>, <Ident>)]`,
/// where `<Type>` is the parent message type and `<Ident>` is the identifier of the variant used to construct this child. /// where `<Type>` is the parent message type and `<Ident>` 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 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`. /// 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 /// 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(<Type>, <Type>, <Ident>)]`, where the first `<Type>` is the top parent message type, the secont `<Type>` is the parent message type /// `#[impl_message(<Type>, <Type>, <Ident>)]`, where the first `<Type>` is the top parent message type, the secont `<Type>` is the parent message type
/// and `<Ident>` is the identifier of the variant used to construct this child. /// and `<Ident>` is the identifier of the variant used to construct this child.
/// It derives `ToDiscriminant`, `AsMessage` on the discriminant, and `TransitiveChild` on both. /// 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`. /// 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** /// **This third option will likely change in the future**
#[proc_macro_attribute] #[proc_macro_attribute]
pub fn impl_message(attr: TokenStream, input_item: TokenStream) -> TokenStream { 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())) 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)] /// #[derive(Hint)]
/// pub enum StateMachine { /// pub enum StateMachine {
/// #[hint(rmb = "foo", lmb = "bar")] /// #[hint(rmb = "foo", lmb = "bar")]
/// Ready, /// Ready,
/// #[hint(alt = "baz")] /// #[hint(alt = "baz")]
/// RMBDown, /// RMBDown,
/// // no hint (also ok) /// // no hint (also ok)
/// LMBDown /// LMBDown
/// } /// }
/// ``` /// ```
#[proc_macro_derive(Hint, attributes(hint))] #[proc_macro_derive(Hint, attributes(hint))]
@ -239,30 +239,30 @@ pub fn derive_hint(input_item: TokenStream) -> TokenStream {
/// # Example /// # Example
/// ```ignore /// ```ignore
/// match (example_tool_state, event) { /// match (example_tool_state, event) {
/// (ToolState::Ready, Event::MouseDown(mouse_state)) if *mouse_state == MouseState::Left => { /// (ToolState::Ready, Event::MouseDown(mouse_state)) if *mouse_state == MouseState::Left => {
/// #[edge("LMB Down")] /// #[edge("LMB Down")]
/// ToolState::Pending /// ToolState::Pending
/// } /// }
/// (SelectToolState::Pending, Event::MouseUp(mouse_state)) if *mouse_state == MouseState::Left => { /// (SelectToolState::Pending, Event::MouseUp(mouse_state)) if *mouse_state == MouseState::Left => {
/// #[edge("LMB Up: Select Object")] /// #[edge("LMB Up: Select Object")]
/// SelectToolState::Ready /// SelectToolState::Ready
/// } /// }
/// (SelectToolState::Pending, Event::MouseMove(x,y)) => { /// (SelectToolState::Pending, Event::MouseMove(x,y)) => {
/// #[edge("Mouse Move")] /// #[edge("Mouse Move")]
/// SelectToolState::TransformSelected /// SelectToolState::TransformSelected
/// } /// }
/// (SelectToolState::TransformSelected, Event::MouseMove(x,y)) => { /// (SelectToolState::TransformSelected, Event::MouseMove(x,y)) => {
/// #[egde("Mouse Move")] /// #[egde("Mouse Move")]
/// SelectToolState::TransformSelected /// SelectToolState::TransformSelected
/// } /// }
/// (SelectToolState::TransformSelected, Event::MouseUp(mouse_state)) if *mouse_state == MouseState::Left => { /// (SelectToolState::TransformSelected, Event::MouseUp(mouse_state)) if *mouse_state == MouseState::Left => {
/// #[edge("LMB Up")] /// #[edge("LMB Up")]
/// SelectToolState::Ready /// SelectToolState::Ready
/// } /// }
/// (state, _) => { /// (state, _) => {
/// // Do nothing /// // Do nothing
/// state /// state
/// } /// }
/// } /// }
/// ``` /// ```
#[proc_macro_attribute] #[proc_macro_attribute]