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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#![warn(unsafe_code)]
#![warn(missing_copy_implementations)]
#![warn(missing_debug_implementations)]
#![feature(generators, generator_trait)]
#![feature(type_ascription)]
#![feature(marker_trait_attr)]
pub mod generator;
pub mod shared;
pub mod singleton;
pub mod cartesian;
pub use enso_shapely_macros::*;
pub use generator::GeneratingIterator;
#[macro_export]
macro_rules! replace {
($a:tt,$($b:tt)*) => {$($b)*}
}
#[macro_export]
macro_rules! newtype_prim_no_derives {
($( $(#$meta:tt)* $name:ident($type:ty); )*) => {$(
$(#$meta)*
pub struct $name {
raw:$type
}
impl $name {
pub const fn new(raw:$type) -> Self {
Self {raw}
}
}
impl Deref for $name {
type Target = $type;
fn deref(&self) -> &Self::Target {
&self.raw
}
}
impl DerefMut for $name {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.raw
}
}
impl From<$type> for $name { fn from(t:$type) -> Self { Self::new(t) } }
impl From<&$type> for $name { fn from(t:&$type) -> Self { Self::new(*t) } }
impl From<&&$type> for $name { fn from(t:&&$type) -> Self { Self::new(**t) } }
impl From<$name> for $type { fn from(t:$name) -> Self { t.raw } }
impl From<&$name> for $type { fn from(t:&$name) -> Self { t.raw } }
impl From<&&$name> for $type { fn from(t:&&$name) -> Self { t.raw } }
)*}
}
#[macro_export]
macro_rules! newtype_prim {
($( $(#$meta:tt)* $name:ident($type:ty); )*) => {
$crate::newtype_prim_no_derives! {
$(
$(#$meta)*
#[derive(Copy,Clone,CloneRef,Debug,Default,Display,Eq,Hash,Ord,PartialOrd,PartialEq)]
$name($type);
)*
}
}
}
#[macro_export]
macro_rules! newtype_prim_no_default {
($( $(#$meta:tt)* $name:ident($type:ty); )*) => {
$crate::newtype_prim_no_derives! {
$(
$(#$meta)*
#[derive(Copy,Clone,CloneRef,Debug,Display,Eq,Hash,Ord,PartialOrd,PartialEq)]
$name($type);
)*
}
}
}
#[macro_export]
macro_rules! newtype_prim_no_default_no_display {
($( $(#$meta:tt)* $name:ident($type:ty); )*) => {
$crate::newtype_prim_no_derives! {
$(
$(#$meta)*
#[derive(Copy,Clone,CloneRef,Debug,Eq,Hash,Ord,PartialOrd,PartialEq)]
$name($type);
)*
}
}
}
#[macro_export]
macro_rules! derive_clone_plus {
($name:ident) => {
impl<T:Clone+Into<$name>> From<&T> for $name {
fn from(t: &T) -> Self {
t.clone().into()
}
}
}
}