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
60
61
62
63
64
pub mod bitflags;
pub mod bithelpers;
pub mod minmax;
pub mod rand;

macro_rules! dev {
    ($expression: expr) => {
        if cfg!(feature = "dev") {
            $expression;
        }
    };
}

macro_rules! percent {
    ($from: expr, $all: expr) => {
        (($from as f32) / ($all as f32)) * 100.0
    };
}

macro_rules! param {
    ($a : ident . $b : ident . $c : ident) => {
        if cfg!(feature = "dev") {
            $a.$b.$c
        } else {
            crate::engine::params::SearchParams::$c
        }
    };
}

macro_rules! panic_fast {
    ($fmt:expr) => ({
        if cfg!(feature = "dev") {
            panic!(concat!($fmt, "\n"));
        } else {
            std::process::abort();
        }
    });
    ($fmt:expr, $($arg:tt)*) => (
    {
        if cfg!(feature = "dev") {
            panic!(concat!($fmt, "\n"), $($arg)*);
        } else {
            std::process::abort();
        }
    });
}

macro_rules! assert_fast {
    ($($arg:tt)*) => {
        if cfg!(debug_assertions) {
            debug_assert!($($arg)*);
        } else {
            if !($($arg)*) {
                unsafe { std::hint::unreachable_unchecked() };
            }
        }
    };
}

pub(crate) use assert_fast;
pub(crate) use dev;
pub(crate) use panic_fast;
pub(crate) use param;
pub(crate) use percent;