//! A library implementation of so-called `static_assert` based on a macro which
//! conditionally expands into an integer overflow, breaking the compilation.
//!
//! It can take one or more constant boolean expressions as its parameters.
//! When you have multiple conditions to verify, pass them to a single
//! invocation of this macro as multiple parameters.
//!
//! **You cannot invoke this macro more than once in a given scope.**
//! This is because its implementation is based on a type synonym definition and
//! two or more invocation causes name collision.
//!
//! ## Example
//! ```
//! #[macro_use]
//! extern crate static_assert_macro;
//!
//! static_assert!(0 < 1, 1 < 2, 2 < 3);
//!
//! fn main() {
//!     const FOUR: i32 = 4;
//!     static_assert!(1 + 2 == { FOUR - 1 });
//! }
//! ```

#[macro_export]
macro_rules! static_assert {
    (let $e:expr; ) => (
        type _ArrayForStaticAssert = [i8; 0 - ((false == ($e)) as usize)];
    );

    (let $e:expr; $e1:expr $(, $ee:expr)*) => (
        static_assert!(let ($e) && ($e1); $($ee),*);
    );

    ($e:expr $(, $ee:expr)*) => (
        static_assert!(let $e; $($ee),*);
    );
}

#[cfg(test)]
mod tests {
    const _FOUR: i32 = 4;

    #[test]
    fn test_0() {
        static_assert!(1 + 2 == { _FOUR - 1 }, 2 < 3);
    }
}

//! A library implementation of so-called `static_assert` based on a macro which
//! conditionally expands into an integer overflow, breaking the compilation.
//!
//! It can take one or more constant boolean expressions as its parameters.
//! When you have multiple conditions to verify, pass them to a single
//! invocation of this macro as multiple parameters.
//!
//! **You cannot invoke this macro more than once in a given scope.**
//! This is because its implementation is based on a type synonym definition and
//! two or more invocation causes name collision.
//!
//! ## Example
//! ```
//! #[macro_use]
//! extern crate static_assert_macro;
//!
//! static_assert!(0 < 1, 1 < 2, 2 < 3);
//!
//! fn main() {
//!     const FOUR: i32 = 4;
//!     static_assert!(1 + 2 == { FOUR - 1 });
//! }
//! ```

#[macro_export]
macro_rules! static_assert {
    (let $e:expr; ) => (
        type _ArrayForStaticAssert = [i8; 0 - ((false == ($e)) as usize)];
    );

    (let $e:expr; $e1:expr $(, $ee:expr)*) => (
        static_assert!(let ($e) && ($e1); $($ee),*);
    );

    ($e:expr $(, $ee:expr)*) => (
        static_assert!(let $e; $($ee),*);
    );
}

--- 
+++ 
@@ -36,3 +36,13 @@
         static_assert!(let $e; $($ee),*);
     );
 }
+
+#[cfg(test)]
+mod tests {
+    const _FOUR: i32 = 4;
+
+    #[test]
+    fn test_0() {
+        static_assert!(1 + 2 == { _FOUR - 1 }, 2 < 3);
+    }
+}
Add a unit test module

Doctests seem to suppress warnings (note PR #1 was about the "unused type" warning)

Signed-off-by: NODA, Kai <a445972a03eaa731f8b4469e4f864a9a57c01ed3@gmail.com>
