Update rustfmt to 0.3.8

This commit is contained in:
강동윤 2018-03-02 15:07:09 +09:00
parent 171abda3c0
commit 27d9b1e154
3 changed files with 35 additions and 26 deletions

View File

@ -1,4 +1,4 @@
required_version = "0.3.5"
required_version = "0.3.8"
reorder_imports = true
reorder_imports_in_group = true
reorder_imported_names = true

View File

@ -7,8 +7,10 @@ pub enum Tokens {
#[kind(is_a)]
#[kind(prec = "7")]
A,
#[kind(prec = "6")] StructLike {},
#[kind(prec = "5")] TupleLike(u8),
#[kind(prec = "6")]
StructLike {},
#[kind(prec = "5")]
TupleLike(u8),
#[kind(prec = "6")]
#[cfg(feature = "not-used")]
@ -25,13 +27,16 @@ fn simple_bool() {
#[derive(Debug, Kind)]
#[kind(functions(wanted = "bool"))]
pub enum Delegate {
#[kind(wanted)] Wanted,
#[kind(delegate)] May(Del),
#[kind(wanted)]
Wanted,
#[kind(delegate)]
May(Del),
}
#[derive(Debug, Kind)]
#[kind(functions(wanted = "bool"))]
pub enum Del {
#[kind(wanted)] Yes,
#[kind(wanted)]
Yes,
No,
}

View File

@ -7,61 +7,65 @@ extern crate proc_macro2;
#[macro_use]
extern crate quote;
extern crate swc_macros_common;
#[macro_use]
extern crate syn;
use swc_macros_common::prelude::*;
/// Creates `.as_str()` and then implements `Debug` and `Display` using it.
///
///# Input
///
///# Input
/// Enum with \`str_value\`-style **doc** comment for each variant.
///
///
/// e.g.
///
/// ```no_run
///
///```no_run
/// pub enum BinOp {
/// /// `+`
/// Add,
/// /// `-`
/// Minus,
/// }
///
/// ```
///
///
/// Currently, \`str_value\` must be live in it's own line.
///
///
///# Output
///
/// - `pub fn as_str(&self) -> &'static str`
/// - `impl Debug`
/// - `impl Display`
///
///
///# Example
///
/// ```
///
///
///```
///
/// #[macro_use]
/// extern crate string_enum;
///
/// #[derive(StringEnum)]
/// pub enum Tokens {
/// ///`a`
/// A,
/// ///`struct-like`
/// StructLike {},
/// /// `tuple-like`
/// TupleLike(u8),
/// /// `a`
/// A,
/// ///`struct-like`
/// StructLike {},
/// /// `tuple-like`
/// TupleLike(u8),
/// }
/// # fn main() {
///
/// assert_eq!(Tokens::A.as_str(), "a");
/// assert_eq!(Tokens::StructLike {}.as_str(), "struct-like");
/// assert_eq!(Tokens::TupleLike(13).as_str(), "tuple-like");
///
/// assert_eq!(Tokens::A.to_string(), "a");
/// assert_eq!(format!("{:?}", Tokens::A), "a");
/// assert_eq!(format!("{:?}", Tokens::A), format!("{:?}", "a"));
///
/// # }
/// ```
///
///
/// All formatting flags are handled correctly.
#[proc_macro_derive(StringEnum)]
pub fn derive_string_enum(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = syn::parse::<syn::DeriveInput>(input)