algosul_core/
lib.rs

1#![feature(extend_one)]
2#![feature(impl_trait_in_assoc_type)]
3#![feature(negative_impls)]
4#[cfg(feature = "codegen")]
5pub mod codegen;
6#[cfg(feature = "deps")]
7pub mod deps;
8pub mod utils;
9#[macro_export]
10macro_rules! mod_all_os {
11    {$vis:vis} => {
12        #[cfg(unix)]
13        $vis mod unix;
14        #[cfg(target_os = "linux")]
15        $vis mod linux;
16        #[cfg(target_os = "macos")]
17        $vis mod macos;
18        #[cfg(windows)]
19        $vis mod windows;
20        #[cfg(target_os = "ios")]
21        $vis mod ios;
22        #[cfg(target_os = "android")]
23        $vis mod android;
24    };
25}
26#[macro_export]
27macro_rules! args {
28
29  // condition pat
30  (
31    $args:ident: if let $pat:pat = $ok:expr =>
32    $(@$oper:ident)? $arg:expr $(; $($rest:tt)*)?
33  ) => {
34    if let $pat = $ok {
35      $crate::args!($args: $(@$oper)? $arg);
36    }
37    $($crate::args!($args: $($rest)*);)?
38  };
39
40  // condition
41  (
42    $args:ident: if $condition:expr =>
43    $(@$oper:ident)? $arg:expr $(; $($rest:tt)*)?
44  ) => {
45    if $condition {
46      $crate::args!($args: $(@$oper)? $arg);
47    }
48    $($crate::args!($args: $($rest)*);)?
49  };
50
51  // pat
52  (
53    $args:ident: let $pat:pat = $ok:expr =>
54    $(@$oper:ident)? $arg:expr $(; $($rest:tt)*)?
55  ) => {
56    {
57      let $pat = $ok;
58      $crate::args!($args: $(@$oper)? $arg);
59    }
60    $($crate::args!($args: $($rest)*);)?
61  };
62
63  // simple
64  ($args:ident: $(@$oper:ident)? $arg:expr $(; $($rest:tt)*)?) => {
65    $crate::arg!($args: $(@$oper)? $arg);
66    $($crate::args!($args: $($rest)*);)?
67  };
68
69  // empty
70  ($args:ident: ) => {};
71}
72
73#[macro_export]
74macro_rules! arg {
75    // push
76  ($args:ident: @push $arg:expr) => {
77    $args.push($arg)
78  };
79
80  // map push
81  ($args:ident: @map $arg:expr) => {
82    $args.push($crate::utils::std::MapToArg::map_to_arg($arg))
83  };
84
85  // extend
86  ($args:ident: @extend $arg:expr) => {
87    $args.extend($arg)
88  };
89
90  // map extend
91  ($args:ident: @maps $arg:expr) => {
92    $args.extend($crate::utils::std::MapToArgs::map_to_args($arg))
93  };
94
95  // default
96  ($args:ident: $arg:expr) => {
97    $crate::arg!($args: @maps $arg)
98  };
99}