1
0
mirror of https://github.com/danog/strum.git synced 2024-11-30 04:28:59 +01:00

Run rustfmt over the whole tree

This commit is contained in:
Peter Glotfelty 2021-11-19 16:10:52 -08:00
parent 1e3acb64a7
commit a1464c5bc2
5 changed files with 26 additions and 21 deletions

View File

@ -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<T>
where
T: ?Sized,

View File

@ -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);
@ -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()
}

View File

@ -103,8 +103,7 @@ pub fn from_repr_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
},
};
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);

View File

@ -18,8 +18,7 @@ pub fn from_string_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
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;