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

Update strum to Rust edition 2018 (#110)

* Set all crates to edition 2018

* Remove redundant imports

* Remove extern crate declarations for cargo dependencies
This commit is contained in:
Jonas Platte 2020-09-17 20:21:21 +02:00 committed by GitHub
parent c9e1a0e16d
commit b517f232aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 49 additions and 136 deletions

View File

@ -23,18 +23,6 @@ strum = "0.19"
strum_macros = "0.19"
```
And add these lines to the root of your project, either lib.rs or main.rs.
```rust
// Strum contains all the trait definitions
extern crate strum;
#[macro_use]
extern crate strum_macros;
// Instead of #[macro_use], newer versions of rust should prefer
use strum_macros::{Display, EnumIter}; // etc.
```
# Strum Macros
Strum has implemented the following macros:

View File

@ -1,6 +1,7 @@
[package]
name = "strum"
version = "0.19.2"
edition = "2018"
authors = ["Peter Glotfelty <peter.glotfelty@microsoft.com>"]
license = "MIT"

View File

@ -20,16 +20,6 @@
//! strum_macros = "0.18.0"
//! ```
//!
//! And add these lines to the root of your project, either lib.rs or main.rs.
//!
//! ```rust
//! // Strum contains all the trait definitions
//! extern crate strum;
//! #[macro_use]
//! extern crate strum_macros;
//! # fn main() {}
//! ```
//!
//! # Strum Macros
//!
//! Strum has implemented the following macros:
@ -92,16 +82,14 @@ impl std::error::Error for ParseError {
/// # Example
///
/// ```rust
/// # extern crate strum;
/// # #[macro_use] extern crate strum_macros;
/// # use std::fmt::Debug;
/// // You need to bring the type into scope to use it!!!
/// use strum::IntoEnumIterator;
/// use strum::{EnumIter, IntoEnumIterator};
///
/// #[derive(EnumIter,Debug)]
/// #[derive(EnumIter, Debug)]
/// enum Color {
/// Red,
/// Green { range:usize },
/// Green { range: usize },
/// Blue(usize),
/// Yellow,
/// }
@ -117,9 +105,7 @@ impl std::error::Error for ParseError {
/// }
/// }
///
/// fn main() {
/// generic_iterator::<Color, _>(|color| println!("{:?}", color));
/// }
/// ```
pub trait IntoEnumIterator: Sized {
type Iterator: Iterator<Item = Self>;
@ -134,8 +120,6 @@ pub trait IntoEnumIterator: Sized {
/// # Example
///
/// ```rust
/// # extern crate strum;
/// # #[macro_use] extern crate strum_macros;
/// # use std::fmt::Debug;
/// // You need to bring the type into scope to use it!!!
/// use strum::EnumMessage;
@ -149,10 +133,8 @@ pub trait IntoEnumIterator: Sized {
/// Cat,
/// }
///
/// fn main() {
/// let my_pet = Pet::Dog;
/// assert_eq!("I have a dog", my_pet.get_message().unwrap());
/// }
/// ```
pub trait EnumMessage {
fn get_message(&self) -> Option<&str>;
@ -169,8 +151,6 @@ pub trait EnumMessage {
/// # Example
///
/// ```rust
/// # extern crate strum;
/// # #[macro_use] extern crate strum_macros;
/// # use std::fmt::Debug;
/// // You need to bring the type into scope to use it!!!
/// use strum::EnumProperty;
@ -186,10 +166,8 @@ pub trait EnumMessage {
/// Science,
/// }
///
/// fn main() {
/// let history = Class::History;
/// assert_eq!("Ms.Frizzle", history.get_str("Teacher").unwrap());
/// }
/// ```
pub trait EnumProperty {
fn get_str(&self, prop: &str) -> Option<&'static str>;
@ -225,11 +203,6 @@ pub trait VariantNames {
const VARIANTS: &'static [&'static str];
}
#[cfg(feature = "derive")]
#[allow(unused_imports)]
#[macro_use]
extern crate strum_macros;
#[cfg(feature = "derive")]
#[doc(hidden)]
pub use strum_macros::*;

View File

@ -1,6 +1,7 @@
[package]
name = "strum_macros"
version = "0.19.2"
edition = "2018"
authors = ["Peter Glotfelty <peter.glotfelty@microsoft.com>"]
license = "MIT"

View File

@ -9,13 +9,7 @@
#![recursion_limit = "128"]
extern crate heck;
#[macro_use]
extern crate syn;
#[macro_use]
extern crate quote;
extern crate proc_macro;
extern crate proc_macro2;
mod helpers;
mod macros;

View File

@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use syn;
use quote::quote;
pub(crate) fn enum_count_inner(ast: &syn::DeriveInput) -> TokenStream {
let n = match ast.data {

View File

@ -1,5 +1,6 @@
use proc_macro2::{Span, TokenStream};
use syn;
use quote::quote;
use syn::parse_quote;
use crate::helpers::HasTypeProperties;

View File

@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use syn;
use quote::quote;
use crate::helpers::HasStrumVariantProperties;

View File

@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use syn;
use quote::quote;
use crate::helpers::{HasStrumVariantProperties, HasTypeProperties};

View File

@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use syn;
use quote::quote;
use crate::helpers::HasStrumVariantProperties;

View File

@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use syn;
use quote::quote;
use crate::helpers::{HasStrumVariantProperties, HasTypeProperties};

View File

@ -1,5 +1,6 @@
use proc_macro2::TokenStream;
use syn;
use quote::quote;
use syn::parse_quote;
use crate::helpers::{HasStrumVariantProperties, HasTypeProperties};

View File

@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use syn;
use quote::quote;
use crate::helpers::{HasStrumVariantProperties, HasTypeProperties};

View File

@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use syn;
use quote::quote;
use crate::helpers::{HasStrumVariantProperties, HasTypeProperties};

View File

@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use syn;
use quote::quote;
use crate::helpers::{HasStrumVariantProperties, HasTypeProperties};

View File

@ -1,6 +1,7 @@
[package]
name = "strum_tests"
version = "0.19.0"
edition = "2018"
authors = ["Peter Glotfelty <peglotfe@microsoft.com>"]
[dependencies]

View File

@ -1,7 +1,4 @@
#![allow(unused_imports)]
extern crate strum;
#[macro_use]
extern crate strum_macros;
use strum::*;
#[allow(dead_code)]

View File

@ -1,6 +1,4 @@
extern crate strum;
#[macro_use]
extern crate strum_macros;
use strum::{EnumCount, EnumDiscriminants, EnumString, ToString};
#[allow(dead_code)]
#[derive(Debug, Eq, PartialEq, EnumString, ToString, EnumCount, EnumDiscriminants)]

View File

@ -1,5 +1,4 @@
#[macro_use]
extern crate strum_macros;
use strum_macros::AsRefStr;
#[derive(Debug, Eq, PartialEq, AsRefStr)]
enum Color {

View File

@ -1,9 +1,5 @@
extern crate strum;
#[macro_use]
extern crate strum_macros;
use std::str::FromStr;
use strum::AsStaticRef;
use strum::{AsRefStr, AsStaticRef, AsStaticStr, EnumString, IntoStaticStr};
#[derive(Debug, Eq, PartialEq, EnumString, AsRefStr, AsStaticStr, IntoStaticStr)]
enum Color {

View File

@ -1,6 +1,4 @@
extern crate strum;
#[macro_use]
extern crate strum_macros;
use strum::{Display, EnumString};
#[derive(Debug, Eq, PartialEq, EnumString, Display)]
enum Color {

View File

@ -1,8 +1,4 @@
extern crate strum;
#[macro_use]
extern crate strum_macros;
use strum::{EnumCount, IntoEnumIterator};
use strum::{EnumCount, EnumIter, IntoEnumIterator};
#[derive(Debug, EnumCount, EnumIter)]
enum Week {

View File

@ -1,10 +1,5 @@
extern crate strum;
#[macro_use]
extern crate strum_macros;
#[macro_use]
extern crate enum_variant_type;
use strum::IntoEnumIterator;
use enum_variant_type::EnumVariantType;
use strum::{Display, EnumDiscriminants, EnumIter, EnumString, IntoEnumIterator};
#[allow(dead_code)]
#[derive(Debug, Eq, PartialEq, EnumDiscriminants)]

View File

@ -1,8 +1,4 @@
extern crate strum;
#[macro_use]
extern crate strum_macros;
use strum::IntoEnumIterator;
use strum::{EnumIter, IntoEnumIterator};
#[derive(Debug, Eq, PartialEq, EnumIter)]
enum Week {

View File

@ -1,8 +1,3 @@
#![allow(unused_imports)]
extern crate strum;
#[macro_use]
extern crate strum_macros;
use strum::EnumMessage;
#[derive(Debug, Eq, PartialEq, EnumMessage)]

View File

@ -1,8 +1,3 @@
#![allow(unused_imports)]
extern crate strum;
#[macro_use]
extern crate strum_macros;
use strum::EnumProperty;
#[derive(Debug, EnumProperty)]

View File

@ -1,9 +1,5 @@
#[macro_use]
extern crate strum_macros;
#[macro_use]
extern crate structopt;
extern crate strum;
use strum::VariantNames;
use structopt::StructOpt;
use strum::{EnumString, EnumVariantNames, VariantNames};
#[test]
fn simple() {

View File

@ -1,8 +1,5 @@
extern crate strum;
#[macro_use]
extern crate strum_macros;
use std::str::FromStr;
use strum::EnumString;
#[derive(Debug, Eq, PartialEq, EnumString)]
enum Color {

View File

@ -1,10 +1,7 @@
/// test serialize_all cooperation with other macroses
extern crate strum;
#[macro_use]
extern crate strum_macros;
use std::str::FromStr;
use std::string::ToString;
use strum::{EnumString, IntoStaticStr, ToString};
#[derive(Debug, Eq, PartialEq, EnumString, ToString, IntoStaticStr)]
#[strum(serialize_all = "title_case")]

View File

@ -1,9 +1,6 @@
extern crate strum;
#[macro_use]
extern crate strum_macros;
use std::str::FromStr;
use std::string::ToString;
use strum::{EnumString, ToString};
#[derive(Debug, Eq, PartialEq, EnumString, ToString)]
enum Color {

View File

@ -1,6 +1,7 @@
[package]
name = "strum_tests_rename"
version = "0.19.0"
edition = "2018"
authors = ["Peter Glotfelty <peglotfe@microsoft.com>"]
[dependencies]

View File

@ -1,8 +1,7 @@
extern crate strum;
#[macro_use]
extern crate strum_macros;
use strum::*;
#[derive(StrumEnumString,
#[derive(
StrumEnumString,
StrumAsRefStr,
StrumAsStaticStr,
StrumIntoStaticStr,
@ -11,7 +10,8 @@ extern crate strum_macros;
StrumEnumMessage,
StrumEnumProperty,
StrumEnumDiscriminants,
StrumEnumCount)]
StrumEnumCount,
)]
pub enum Color {
Red,
Blue,
@ -23,5 +23,5 @@ pub enum Color {
pub enum Color2 {
Red,
Blue,
Green
Green,
}