rk_utils/
lib.rs

1#![doc = include_str!("../README.md")]
2
3mod str;
4mod topo_sort;
5mod trie;
6
7pub use crate::str::StringUtil;
8pub use crate::topo_sort::{topo_sort, DepGraph};
9pub use crate::trie::Trie;
10
11#[macro_export]
12macro_rules! to_matches {
13    // to_matches!(Enum::variant(val) if val > 0)
14    ($pattern:pat $(if $guard:expr)? $(,)?) => {
15        |ttt| match ttt {
16            $pattern $(if $guard)? => true,
17            _ => false
18        }
19    };
20}
21
22#[macro_export]
23macro_rules! e_value {
24    // e_value!(enum_value, Enum::variant)
25    ($enum:expr, $variant:pat) => {
26        match $enum {
27            $variant(val) => Some(val),
28            _ => None,
29        }
30    };
31    // e_value!(enum_value, Enum::variant if val > 0)
32    ($enum:expr, $variant:pat $(if $guard:expr)? $(,)?) => {
33        match $enum {
34            $variant(val) $(if $guard)? => Some(val),
35            _ => None,
36        }
37    };
38}
39
40#[cfg(test)]
41mod tests;