Repository: Peternator7/strum (Rust)

Issue:
EnumIter does not work for enums named 'Option'
I'm using some code that has generated structs and enums, and some of the enumerations are called `Option`. They are on their own module/crate but there seems to be a conflict with the std::option::Option.

The following does work (note Options, not Option as the name of the enum)

```rust
#[derive(strum_macros::EnumIter, Debug)]
pub enum Options {
    Open,
    Closed,
}

use strum::IntoEnumIterator;
fn main() {
    for variant in crate::Options::iter() {
        println!("The door is {:?}", variant);
    }
}

```

the following does not work (the name of the enum is now Option)
```rust
#[derive(strum_macros::EnumIter, Debug)]
pub enum Option {
    Open,
    Closed,
}

use strum::IntoEnumIterator;
fn main() {
    for variant in crate::Option::iter() {
        println!("The door is {:?}", variant);
    }
}

```


Discussion:

Patch:
diff --git a/strum_macros/src/macros/enum_iter.rs b/strum_macros/src/macros/enum_iter.rs
index ce8237f8..0e700aa0 100644
--- a/strum_macros/src/macros/enum_iter.rs
+++ b/strum_macros/src/macros/enum_iter.rs
@@ -91,7 +91,7 @@ pub fn enum_iter_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
         }
 
         impl #impl_generics #iter_name #ty_generics #where_clause {
-            fn get(&self, idx: usize) -> Option<#name #ty_generics> {
+            fn get(&self, idx: usize) -> ::core::option::Option<#name #ty_generics> {
                 match idx {
                     #(#arms),*
                 }
@@ -112,16 +112,16 @@ pub fn enum_iter_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
         impl #impl_generics Iterator for #iter_name #ty_generics #where_clause {
             type Item = #name #ty_generics;
 
-            fn next(&mut self) -> Option<<Self as Iterator>::Item> {
+            fn next(&mut self) -> ::core::option::Option<<Self as Iterator>::Item> {
                 self.nth(0)
             }
 
-            fn size_hint(&self) -> (usize, Option<usize>) {
+            fn size_hint(&self) -> (usize, ::core::option::Option<usize>) {
                 let t = if self.idx + self.back_idx >= #variant_count { 0 } else { #variant_count - self.idx - self.back_idx };
                 (t, Some(t))
             }
 
-            fn nth(&mut self, n: usize) -> Option<<Self as Iterator>::Item> {
+            fn nth(&mut self, n: usize) -> ::core::option::Option<<Self as Iterator>::Item> {
                 let idx = self.idx + n + 1;
                 if idx + self.back_idx > #variant_count {
                     // We went past the end of the iterator. Freeze idx at #variant_count
@@ -143,7 +143,7 @@ pub fn enum_iter_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
         }
 
         impl #impl_generics DoubleEndedIterator for #iter_name #ty_generics #where_clause {
-            fn next_back(&mut self) -> Option<<Self as Iterator>::Item> {
+            fn next_back(&mut self) -> ::core::option::Option<<Self as Iterator>::Item> {
                 let back_idx = self.back_idx + 1;
 
                 if self.idx + back_idx > #variant_count {


Test patch:
diff --git a/strum_tests/tests/enum_iter.rs b/strum_tests/tests/enum_iter.rs
index 313ed5cf..ce6ecb24 100644
--- a/strum_tests/tests/enum_iter.rs
+++ b/strum_tests/tests/enum_iter.rs
@@ -211,3 +211,16 @@ fn crate_module_path_test() {
 
     assert_eq!(expected, results);
 }
+
+#[test]
+fn enum_iter_option() {
+    #[derive(Debug, Eq, PartialEq, EnumIter)]
+    enum Option {
+        BluePill,
+        RedPill,
+    }
+    let results = Option::iter().collect::<Vec<_>>();
+    let expected = vec![Option::BluePill, Option::RedPill];
+
+    assert_eq!(expected, results);
+}