1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#[macro_export]
macro_rules! throw {
    ($msg:literal $(,)?) => { {
        ::ez::__::Err(::ez::Error::msg($msg))?;
        unreachable!()
    } };

    ($msg:literal $(, $rest:tt)* $(,)?) => { {
        ::ez::__::Err(::ez::Error::msg(format!($msg $(, $rest)*)))?;
        unreachable!()
    } };

    ($error:expr $(,)?) => { {
        ::ez::__::Err($error)?;
        unreachable!()
    } };

    ($(,)?) => { {
        ::ez::__::Err(::ez::__::core::default::Default::default())?;
        unreachable!()
    } };
}

#[macro_export]
macro_rules! publish {
    {
        pub use $path:path $(as $name:ident)?;
        $(prose from $doc:literal;)*
        $(example $example:ident;)*
        $(failing example $failing:ident;)*
    } => {
        $(
        ///
        #[doc = include_str!(concat!("./", $doc))]
        ///
        )*
        $(
        ///
        #[doc = concat!("## Example `", stringify!($example), "`")]
        ///
        /// ```rust
        /// # use ez::__::*;
        #[doc = include_str!(concat!("../examples/", stringify!($example), ".rs"))]
        /// ```
        )*
        $(
        ///
        #[doc = concat!("## Example `", stringify!($failing), "`")]
        ///
        /// ```should_panic
        /// # use ez::__::*;
        #[doc = include_str!(concat!("../examples/", stringify!($failing), ".rs"))]
        /// ```
        )*
        ///
        #[doc(inline)]
        pub use $path $(as $name)?;
    }
}