about summary refs log tree commit diff stats
path: root/crates/core/src/lib.rs
blob: 0b40bbdfd218dfd5c74e1e6917dc213a47622a8c (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
#![cfg_attr(not(test), no_std)]
#![feature(allocator_api)]
#![feature(vec_push_within_capacity)]
#![feature(trusted_len)]
#![feature(assert_matches)]
#![feature(stmt_expr_attributes)]
#![feature(const_trait_impl)]
#![feature(const_option_ops)]
#![feature(const_result_trait_fn)]
#![feature(const_convert)]
#![feature(const_default)]
#![feature(const_clone)]
#![feature(cmp_minmax)]

//! A highly portable computer algebra system library implemented in Rust.

extern crate alloc;

pub mod egraph;
pub mod expressions;
pub mod id;
pub mod numerics;
pub mod utilities;

/// Asserts a condition at compile time.
#[macro_export]
macro_rules! static_assert {
    ($cond:expr $(,)?) => {
        const _: () = {
            if !$cond {
                panic!(concat!(
                    "static assertion failed: ",
                    stringify!($cond),
                ));
            }
        };
    };
    ($cond:expr, $msg:literal $(,)?) => {
        const _: () = {
            if !$cond {
                panic!($msg);
            }
        };
    };
}

/// Asserts equality at compile time.
#[macro_export]
macro_rules! static_assert_eq {
    ($a:expr, $b:expr $(,)?) => {
        const _: () = {
            if $a != $b {
                panic!(concat!(
                    "static assertion failed: ",
                    stringify!($a),
                    " == ",
                    stringify!($b),
                ));
            }
        };
    };
    ($a:expr, $b:expr, $msg:literal $(,)?) => {
        const _: () = {
            if $a != $b {
                panic!(concat!(
                    "static assertion failed: ",
                    stringify!($a),
                    " == ",
                    stringify!($b),
                    ": ",
                    $msg,
                ));
            }
        };
    };
}