From fff0cf3f41e5dd3157e0c5790b0e12e43fb8099b Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 26 Nov 2021 14:31:05 +0100 Subject: [PATCH] Remove enum_iterator It is used only in mk_enum and the macro knows already its variants so it can be manually implemented. --- Cargo.lock | 21 --------------------- Cargo.toml | 1 - enums/src/go.rs | 1 - enums/src/json.rs | 1 - enums/src/languages.rs | 1 - enums/src/lib.rs | 1 - enums/src/rust.rs | 1 - src/langs.rs | 1 - src/macros.rs | 8 +++++++- 9 files changed, 7 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cffe4d8e0..41cd1cfcb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -692,26 +692,6 @@ dependencies = [ "syn", ] -[[package]] -name = "enum-iterator" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "fixedbitset" version = "0.4.0" @@ -1600,7 +1580,6 @@ name = "rust-code-analysis" version = "0.0.23" dependencies = [ "aho-corasick", - "enum-iterator", "fxhash", "lazy_static", "num", diff --git a/Cargo.toml b/Cargo.toml index 9e98bc638..5282f600c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ license = "MPL-2.0" [dependencies] aho-corasick = "^0.7" -enum-iterator = "^0.7" fxhash = "0.2" lazy_static = "^1.3" num-format = "^0.4" diff --git a/enums/src/go.rs b/enums/src/go.rs index 7f6a57762..d69d227e2 100644 --- a/enums/src/go.rs +++ b/enums/src/go.rs @@ -1,5 +1,4 @@ use askama::Template; -use enum_iterator::IntoEnumIterator; use std::fs::File; use std::io::Write; use std::path::PathBuf; diff --git a/enums/src/json.rs b/enums/src/json.rs index 906f73dc1..cf9843870 100644 --- a/enums/src/json.rs +++ b/enums/src/json.rs @@ -1,5 +1,4 @@ use askama::Template; -use enum_iterator::IntoEnumIterator; use std::fs::File; use std::io::Write; use std::path::PathBuf; diff --git a/enums/src/languages.rs b/enums/src/languages.rs index 73ed6e343..c5a105352 100644 --- a/enums/src/languages.rs +++ b/enums/src/languages.rs @@ -1,4 +1,3 @@ -use enum_iterator::IntoEnumIterator; use tree_sitter::Language; use crate::*; diff --git a/enums/src/lib.rs b/enums/src/lib.rs index 70c724164..5778236e4 100644 --- a/enums/src/lib.rs +++ b/enums/src/lib.rs @@ -1,5 +1,4 @@ extern crate askama; -extern crate enum_iterator; extern crate tree_sitter; #[macro_use] diff --git a/enums/src/rust.rs b/enums/src/rust.rs index ad13f6686..22fdd5bc0 100644 --- a/enums/src/rust.rs +++ b/enums/src/rust.rs @@ -1,5 +1,4 @@ use askama::Template; -use enum_iterator::IntoEnumIterator; use std::env; use std::fs::File; use std::io::{Read, Write}; diff --git a/src/langs.rs b/src/langs.rs index 9217bbc5c..9eb4fca82 100644 --- a/src/langs.rs +++ b/src/langs.rs @@ -1,4 +1,3 @@ -use enum_iterator::IntoEnumIterator; use std::path::Path; use std::sync::Arc; use tree_sitter::Language; diff --git a/src/macros.rs b/src/macros.rs index 6bdeecdb5..f12e517a8 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -46,13 +46,19 @@ macro_rules! get_language { macro_rules! mk_enum { ( $( $camel:ident, $description:expr ),* ) => { /// The list of supported languages. - #[derive(Clone, Copy, Debug, IntoEnumIterator, PartialEq)] + #[derive(Clone, Copy, Debug, PartialEq)] pub enum LANG { $( #[doc = $description] $camel, )* } + impl LANG { + pub fn into_enum_iter() -> impl Iterator { + use LANG::*; + [$( $camel, )*].into_iter() + } + } }; }