1#![doc(html_favicon_url = "https://zng-ui.github.io/res/zng-logo-icon.png")]
2#![doc(html_logo_url = "https://zng-ui.github.io/res/zng-logo.png")]
3#![doc = include_str!(concat!("../", std::env!("CARGO_PKG_README")))]
9#![warn(unused_extern_crates)]
11#![warn(missing_docs)]
12#![deny(clippy::future_not_send)]
13
14macro_rules! trace_debug_error {
15 ($result:expr) => {
16 if let Err(e) = $result {
17 tracing::debug!("{e}")
18 }
19 };
20}
21
22mod var_value;
23pub use var_value::*;
24
25mod var_any;
26pub use var_any::*;
27
28mod var;
29pub use var::*;
30
31pub(crate) mod var_impl;
32pub use var_impl::*;
33
34pub mod animation;
35
36mod vars;
37pub use vars::*;
38
39mod vec;
40pub use vec::*;
41
42mod impls;
43
44pub(crate) mod future;
45
46#[macro_export]
97macro_rules! impl_from_and_into_var {
98 ($($tt:tt)+) => {
99 $crate::__impl_from_and_into_var! { $($tt)* }
100 };
101}
102
103#[doc(hidden)]
104#[macro_export]
105macro_rules! __impl_from_and_into_var {
106 (
108 $(#[$docs:meta])*
109 fn from ( $($input:tt)+ )
110 $($rest:tt)+
111 ) => {
112 $crate::__impl_from_and_into_var! {
113 =input=>
114 [
115 input { $($input)+ }
116 generics { }
117 docs { $(#[$docs])* }
118 ]
119 ( $($input)+ ) $($rest)+
120 }
121 };
122 (
124 $(#[$docs:meta])*
125 fn from <
126 $($rest:tt)+
127 ) => {
128 $crate::__impl_from_and_into_var! {
129 =generics=>
130 [
131 generics { < }
132 docs { $(#[$docs])* }
133 ]
134 $($rest)+
135 }
136 };
137 (
139 =generics=>
140 [
141 generics { $($generics:tt)+ }
142 $($config:tt)*
143 ]
144
145 >( $($input:tt)+ ) $($rest:tt)+
146 ) => {
147 $crate::__impl_from_and_into_var! {
148 =input=>
149 [
150 input { $($input)+ }
151 generics { $($generics)+ > }
152 $($config)*
153 ]
154 ( $($input)+ ) $($rest)+
155 }
156 };
157 (
159 =generics=>
160 [
161 generics { $($generics:tt)+ }
162 $($config:tt)*
163 ]
164
165 >>( $($input:tt)+ ) $($rest:tt)+
166 ) => {
167 $crate::__impl_from_and_into_var! {
168 =input=>
169 [
170 input { $($input)+ }
171 generics { $($generics)+ >> }
172 $($config)*
173 ]
174 ( $($input)+ ) $($rest)+
175 }
176 };
177 (
179 =generics=>
180 [
181 generics { $($generics:tt)+ }
182 $($config:tt)*
183 ]
184
185 $tt:tt $($rest:tt)+
186 ) => {
187 $crate::__impl_from_and_into_var! {
189 =generics=>
190 [
191 generics { $($generics)+ $tt }
192 $($config)*
193 ]
194 $($rest)*
195 }
196 };
198 (
200 =input=>
201 [$($config:tt)*]
202 ($ident:ident : $Input:ty $(,)?) $($rest:tt)+
203 ) => {
204 $crate::__impl_from_and_into_var! {
205 =output=>
206 [
207 input_type { $Input }
208 $($config)*
209 ]
210 $($rest)+
211 }
212 };
213 (
215 =input=>
216 [$($config:tt)*]
217 (( $($destructure:tt)+ ) : $Input:ty $(,)?) $($rest:tt)+
218 ) => {
219 $crate::__impl_from_and_into_var! {
220 =output=>
221 [
222 input_type { $Input }
223 $($config)*
224 ]
225 $($rest)+
226 }
227 };
228 (
230 =input=>
231 [$($config:tt)*]
232 ([ $($destructure:tt)+ ] : $Input:ty $(,)?) $($rest:tt)+
233 ) => {
234 $crate::__impl_from_and_into_var! {
235 =output=>
236 [
237 input_type { $Input }
238 $($config)*
239 ]
240 $($rest)+
241 }
242 };
243
244 (
246 =output=>
247 [
248 input_type { $Input:ty }
249 input { $($input:tt)+ }
250 generics { $($generics:tt)* }
251 docs { $($docs:tt)* }
252 ]
253 -> $Output:ty
254 ;
255
256 $($rest:tt)*
257 ) => {
258 impl $($generics)* $crate::IntoVar<$Output> for $Input {
259 $($docs)*
260
261 fn into_var(self) -> $crate::Var<$Output> {
262 $crate::IntoVar::into_var(<$Output as From<$Input>>::from(self))
263 }
264 }
265
266 impl $($generics)* $crate::IntoValue<$Output> for $Input { }
267
268 $crate::__impl_from_and_into_var! {
270 $($rest)*
271 }
272 };
273
274 (
276 =output=>
277 [
278 input_type { $Input:ty }
279 input { $($input:tt)+ }
280 generics { $($generics:tt)* }
281 docs { $($docs:tt)* }
282 ]
283 -> $Output:ty
284 $convert:block
285
286 $($rest:tt)*
287 ) => {
288 impl $($generics)* From<$Input> for $Output {
289 $($docs)*
290
291 fn from($($input)+) -> Self
292 $convert
293 }
294
295 impl $($generics)* $crate::IntoVar<$Output> for $Input {
296 $($docs)*
297
298 fn into_var(self) -> $crate::Var<$Output> {
299 $crate::IntoVar::into_var(<$Output as From<$Input>>::from(self))
300 }
301 }
302
303 impl $($generics)* $crate::IntoValue<$Output> for $Input { }
304
305 $crate::__impl_from_and_into_var! {
307 $($rest)*
308 }
309 };
310
311 () => {
312 };
314}