From a1464c5bc2faba4b85a8bf9b1fb93241758ae92d Mon Sep 17 00:00:00 2001 From: Peter Glotfelty Date: Fri, 19 Nov 2021 16:10:52 -0800 Subject: [PATCH] Run rustfmt over the whole tree --- strum/src/additional_attributes.rs | 12 +++++----- strum/src/lib.rs | 7 +++--- strum_macros/src/lib.rs | 22 ++++++++++++------- strum_macros/src/macros/from_repr.rs | 3 +-- .../src/macros/strings/from_string.rs | 3 +-- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/strum/src/additional_attributes.rs b/strum/src/additional_attributes.rs index a93f827..399ca32 100644 --- a/strum/src/additional_attributes.rs +++ b/strum/src/additional_attributes.rs @@ -1,12 +1,12 @@ //! # Documentation for Additional Attributes -//! +//! //! ## Attributes on Enums //! //! Strum supports several custom attributes to modify the generated code. At the enum level, the following attributes are supported: -//! -//! - `#[strum(serialize_all = "case_style")]` attribute can be used to change the case used when serializing to and deserializing +//! +//! - `#[strum(serialize_all = "case_style")]` attribute can be used to change the case used when serializing to and deserializing //! from strings. This feature is enabled by [withoutboats/heck](https://github.com/withoutboats/heck) and supported case styles are: -//! +//! //! - `camelCase` //! - `PascalCase` //! - `kebab-case` @@ -17,7 +17,7 @@ //! - `UPPERCASE` //! - `title_case` //! - `mixed_case` -//! +//! //! ```rust //! use std::string::ToString; //! use strum; @@ -50,7 +50,7 @@ //! //! - You can also apply the `#[strum(ascii_case_insensitive)]` attribute to the enum, //! and this has the same effect of applying it to every variant. -//! +//! //! ## Attributes on Variants //! //! Custom attributes are applied to a variant by adding `#[strum(parameter="value")]` to the variant. diff --git a/strum/src/lib.rs b/strum/src/lib.rs index aeff2be..912cdb0 100644 --- a/strum/src/lib.rs +++ b/strum/src/lib.rs @@ -24,9 +24,7 @@ //! ``` //! - #![cfg_attr(not(feature = "std"), no_std)] - #![cfg_attr(docsrs, feature(doc_cfg))] // only for documentation purposes @@ -168,7 +166,10 @@ pub trait EnumProperty { /// A cheap reference-to-reference conversion. Used to convert a value to a /// reference value with `'static` lifetime within generic code. -#[deprecated(since="0.22.0", note="please use `#[derive(IntoStaticStr)]` instead")] +#[deprecated( + since = "0.22.0", + note = "please use `#[derive(IntoStaticStr)]` instead" +)] pub trait AsStaticRef where T: ?Sized, diff --git a/strum_macros/src/lib.rs b/strum_macros/src/lib.rs index 9d9ff89..73185fe 100644 --- a/strum_macros/src/lib.rs +++ b/strum_macros/src/lib.rs @@ -192,7 +192,10 @@ pub fn variant_names(input: proc_macro::TokenStream) -> proc_macro::TokenStream } #[proc_macro_derive(AsStaticStr, attributes(strum))] -#[deprecated(since="0.22.0", note="please use `#[derive(IntoStaticStr)]` instead")] +#[deprecated( + since = "0.22.0", + note = "please use `#[derive(IntoStaticStr)]` instead" +)] pub fn as_static_str(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let ast = syn::parse_macro_input!(input as DeriveInput); @@ -272,7 +275,10 @@ pub fn into_static_str(input: proc_macro::TokenStream) -> proc_macro::TokenStrea /// let yellow = Color::Yellow; /// assert_eq!(String::from("Yellow"), yellow.to_string()); /// ``` -#[deprecated(since="0.22.0", note="please use `#[derive(Display)]` instead. See issue https://github.com/Peternator7/strum/issues/132")] +#[deprecated( + since = "0.22.0", + note = "please use `#[derive(Display)]` instead. See issue https://github.com/Peternator7/strum/issues/132" +)] #[proc_macro_derive(ToString, attributes(strum))] pub fn to_string(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let ast = syn::parse_macro_input!(input as DeriveInput); @@ -421,19 +427,19 @@ pub fn enum_iter(input: proc_macro::TokenStream) -> proc_macro::TokenStream { /// /// assert_eq!(None, Vehicle::from_repr(0)); /// ``` -/// +/// /// On versions of rust >= 1.46, the `from_repr` function is marked `const`. -/// +/// /// ```rust /// use strum_macros::FromRepr; -/// +/// /// #[derive(FromRepr, Debug, PartialEq)] /// #[repr(u8)] /// enum Number { /// One = 1, /// Three = 3, /// } -/// +/// /// # #[rustversion::since(1.46)] /// const fn number_from_repr(d: u8) -> Option { /// Number::from_repr(d) @@ -454,8 +460,8 @@ pub fn enum_iter(input: proc_macro::TokenStream) -> proc_macro::TokenStream { pub fn from_repr(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let ast = syn::parse_macro_input!(input as DeriveInput); - let toks = macros::from_repr::from_repr_inner(&ast) - .unwrap_or_else(|err| err.to_compile_error()); + let toks = + macros::from_repr::from_repr_inner(&ast).unwrap_or_else(|err| err.to_compile_error()); debug_print_generated(&ast, &toks); toks.into() } diff --git a/strum_macros/src/macros/from_repr.rs b/strum_macros/src/macros/from_repr.rs index 3ea6d1b..7fdb1b5 100644 --- a/strum_macros/src/macros/from_repr.rs +++ b/strum_macros/src/macros/from_repr.rs @@ -103,8 +103,7 @@ pub fn from_repr_inner(ast: &DeriveInput) -> syn::Result { }, }; - constant_defs - .push(quote! {const #const_var_ident: #discriminant_type = #const_val_expr;}); + constant_defs.push(quote! {const #const_var_ident: #discriminant_type = #const_val_expr;}); arms.push(quote! {v if v == #const_var_ident => ::core::option::Option::Some(#name::#ident #params)}); prev_const_var_ident = Some(const_var_ident); diff --git a/strum_macros/src/macros/strings/from_string.rs b/strum_macros/src/macros/strings/from_string.rs index 2882981..526472e 100644 --- a/strum_macros/src/macros/strings/from_string.rs +++ b/strum_macros/src/macros/strings/from_string.rs @@ -18,8 +18,7 @@ pub fn from_string_inner(ast: &DeriveInput) -> syn::Result { let strum_module_path = type_properties.crate_module_path(); let mut default_kw = None; - let mut default = - quote! { _ => ::core::result::Result::Err(#strum_module_path::ParseError::VariantNotFound) }; + let mut default = quote! { _ => ::core::result::Result::Err(#strum_module_path::ParseError::VariantNotFound) }; let mut arms = Vec::new(); for variant in variants { let ident = &variant.ident;