]> git.lizzy.rs Git - enumset.git/commitdiff
Remove deprecated functionality.
authorLymia Aluysia <lymia@lymiahugs.com>
Mon, 6 May 2019 23:41:48 +0000 (18:41 -0500)
committerLymia Aluysia <lymia@lymiahugs.com>
Mon, 6 May 2019 23:41:48 +0000 (18:41 -0500)
enumset/src/lib.rs
enumset_derive/src/lib.rs

index 5b4e30984636dc100af4f8a4c38821037ecfea6f..c52505af5c1160bf29972e87bbceb3d0c15a863f 100644 (file)
@@ -139,8 +139,8 @@ use private::EnumSetTypeRepr;
 /// if it were an [`EnumSet`] in expressions. This can be disabled by adding an `#[enumset(no_ops)]`
 /// annotation to the enum.
 ///
-/// The custom derive for `EnumSetType` automatically implements [`Copy`] and [`Clone`] on the
-/// enum. These are required for the [`EnumSet`] to function.
+/// The custom derive for `EnumSetType` automatically implements [`Copy`], [`Clone`], [`Eq`], and
+/// [`PartialEq`] on the enum. These are required for the [`EnumSet`] to function.
 ///
 /// Any C-like enum is supported, as long as there are no more than 128 variants in the enum,
 /// and no variant discriminator is larger than 127.
@@ -481,30 +481,6 @@ impl <T : EnumSetType> Iterator for EnumSetIter<T> {
     }
 }
 
-/// Defines enums which can be used with EnumSet.
-///
-/// [`Copy`], [`Clone`], [`PartialOrd`], [`Ord`], [`PartialEq`], [`Eq`], [`Hash`], [`Debug`],
-/// [`Sub`], [`BitAnd`], [`BitOr`], [`BitXor`], and [`Not`] are automatically derived for the enum.
-///
-/// These impls, in general, behave as if the enum variant was an [`EnumSet`] with a single value,
-/// as those created by [`EnumSet::only`].
-#[macro_export]
-#[deprecated(since = "0.3.13", note = "Use `#[derive(EnumSetType)] instead.")]
-macro_rules! enum_set_type {
-    ($(#[$enum_attr:meta])* $vis:vis enum $enum_name:ident {
-        $($(#[$attr:meta])* $variant:ident),* $(,)*
-    } $($rest:tt)*) => {
-        $(#[$enum_attr])* #[repr(u8)]
-        #[derive($crate::EnumSetType, Debug)]
-        $vis enum $enum_name {
-            $($(#[$attr])* $variant,)*
-        }
-
-        enum_set_type!($($rest)*);
-    };
-    () => { };
-}
-
 /// Creates a EnumSet literal, which can be used in const contexts.
 ///
 /// The syntax used is `enum_set!(Type::A | Type::B | Type::C)`. Each variant must be of the same
index f8777439c2b7014365fd050f0a8dec9f35e16c90..45619239eb9fafbac353af30f3011b92a9a36e7f 100644 (file)
@@ -79,40 +79,6 @@ fn enum_set_type_impl(
         }
     };
 
-    let derives = if attrs.no_derives {
-        quote! {}
-    } else {
-        quote! {
-            impl #core::cmp::PartialOrd for #name {
-                fn partial_cmp(&self, other: &Self) -> #core::option::Option<#core::cmp::Ordering> {
-                    (*self as u8).partial_cmp(&(*other as u8))
-                }
-            }
-            impl #core::cmp::Ord for #name {
-                fn cmp(&self, other: &Self) -> #core::cmp::Ordering {
-                    (*self as u8).cmp(&(*other as u8))
-                }
-            }
-            impl #core::cmp::PartialEq for #name {
-                fn eq(&self, other: &Self) -> bool {
-                    (*self as u8) == (*other as u8)
-                }
-            }
-            impl #core::cmp::Eq for #name { }
-            impl #core::hash::Hash for #name {
-                fn hash<H: #core::hash::Hasher>(&self, state: &mut H) {
-                    state.write_u8(*self as u8)
-                }
-            }
-            impl #core::clone::Clone for #name {
-                fn clone(&self) -> Self {
-                    *self
-                }
-            }
-            impl #core::marker::Copy for #name { }
-        }
-    };
-
     #[cfg(feature = "serde")]
     let expecting_str = format!("a list of {}", name);
 
@@ -194,8 +160,20 @@ fn enum_set_type_impl(
             #serde_ops
         }
 
+        impl #core::cmp::PartialEq for #name {
+            fn eq(&self, other: &Self) -> bool {
+                (*self as u8) == (*other as u8)
+            }
+        }
+        impl #core::cmp::Eq for #name { }
+        impl #core::clone::Clone for #name {
+            fn clone(&self) -> Self {
+                *self
+            }
+        }
+        impl #core::marker::Copy for #name { }
+
         #ops
-        #derives
     }
 }
 
@@ -203,7 +181,6 @@ fn enum_set_type_impl(
 #[darling(attributes(enumset), default)]
 struct EnumsetAttrs {
     no_ops: bool,
-    no_derives: bool,
     serialize_as_list: bool,
     #[darling(default)]
     serialize_repr: Option<String>,