]> git.lizzy.rs Git - enumset.git/commitdiff
Rename 'i128' to 'nightly', make EnumSet::new() a const fn.
authorLymia Aluysia <lymia@lymiahugs.com>
Wed, 29 Nov 2017 16:59:34 +0000 (10:59 -0600)
committerLymia Aluysia <lymia@lymiahugs.com>
Wed, 29 Nov 2017 16:59:34 +0000 (10:59 -0600)
Cargo.toml
README.md
src/lib.rs

index 77c4fc44fea7de430b181353a1e86806f06957a0..41ee9d79a44cf483081725bbaf1b456a32c8fdda 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "enumset"
-version = "0.1.2"
+version = "0.2.1"
 authors = ["Lymia Aluysia <lymia@lymiahugs.com>"]
 
 description = "A library for creating compact sets of enums."
@@ -14,4 +14,4 @@ readme = "README.md"
 license = "MIT/Apache-2.0"
 
 [features]
-i128 = []
+nightly = []
index a9572f9ab92c99ee73bdc7ee1d32cb35f56dc91c..f75f68db166ad526d4dcb9932620b8f5602c9d42 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 A library for defining enums that can be used in compact bit sets.
 
-It supports enums up to 64 variants on stable Rust, and up to 128 variants on nightly Rust with the `i128` feature enabled, and has a macro to use these sets in constants.
+It supports enums up to 64 variants on stable Rust, and up to 128 variants on nightly Rust with the `nightly` feature enabled, and has a macro to use these sets in constants.
 
 [See the documentation for more information.](https://docs.rs/enumset)
 
index 4adab293ad9fb9b9f2e1aa235759fa14931f1813..4cf0b7d7c07a4e7f3457c29d5208d0a3fc0b8b29 100644 (file)
@@ -1,9 +1,10 @@
-#![cfg_attr(all(test, feature = "i128"), feature(i128, i128_type))]
+#![cfg_attr(all(test, feature = "nightly"), feature(i128, i128_type))]
+#![cfg_attr(all(feature = "nightly"), feature(const_fn))]
 
 //! A library for defining enums that can be used in compact bit sets.
 //!
 //! It supports enums up to 64 variants on stable Rust, and up to 128 variants on nightly Rust with
-//! the `i128` feature enabled.
+//! the `nightly` feature enabled.
 //!
 //! # Defining enums for use with EnumSet
 //!
@@ -114,10 +115,17 @@ impl <T : EnumSetType> EnumSet<T> {
     }
 
     /// Returns an empty set.
+    #[cfg(not(feature = "nightly"))]
     pub fn new() -> Self {
         EnumSet(T::ZERO)
     }
 
+    /// Returns an empty set.
+    #[cfg(feature = "nightly")]
+    pub const fn new() -> Self {
+        EnumSet(T::ZERO)
+    }
+
     /// Returns the number of values in this set.
     pub fn len(&self) -> usize {
         T::count_ones(self.0)
@@ -268,7 +276,7 @@ impl <T : EnumSetType> Iterator for EnumSetIter<T> {
 
 #[macro_export]
 #[doc(hidden)]
-#[cfg(feature = "i128")]
+#[cfg(feature = "nightly")]
 macro_rules! enum_set_type_internal_count_variants {
     ($next:ident ($($args:tt)*)
         $_00:ident $_01:ident $_02:ident $_03:ident $_04:ident $_05:ident $_06:ident $_07:ident
@@ -333,7 +341,7 @@ macro_rules! enum_set_type_internal_count_variants {
 
 #[macro_export]
 #[doc(hidden)]
-#[cfg(not(feature = "i128"))]
+#[cfg(not(feature = "nightly"))]
 macro_rules! enum_set_type_internal_count_variants {
     ($next:ident ($($args:tt)*)
         $_00:ident $_01:ident $_02:ident $_03:ident $_04:ident $_05:ident $_06:ident $_07:ident
@@ -504,7 +512,7 @@ mod test {
         }
     }
 
-    #[cfg(feature = "i128")]
+    #[cfg(feature = "nightly")]
     enum_set_type! {
         enum LargeEnum {
             _00,  _01,  _02,  _03,  _04,  _05,  _06,  _07,
@@ -535,7 +543,7 @@ mod test {
         A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
     }
 
-    #[cfg(feature = "i128")]
+    #[cfg(feature = "nightly")]
     test_variants! { LargeEnum large_enum_variant_range_test
         _00,  _01,  _02,  _03,  _04,  _05,  _06,  _07,
         _10,  _11,  _12,  _13,  _14,  _15,  _16,  _17,
@@ -630,6 +638,6 @@ mod test {
     }
 
     test_enum!(Enum, small_enum);
-    #[cfg(feature = "i128")]
+    #[cfg(feature = "nightly")]
     test_enum!(LargeEnum, large_enum);
 }