#![doc(html_favicon_url = "https://zng-ui.github.io/res/zng-logo-icon.png")]
#![doc(html_logo_url = "https://zng-ui.github.io/res/zng-logo.png")]
#![doc = include_str!(concat!("../", std::env!("CARGO_PKG_README")))]
#![warn(unused_extern_crates)]
#![warn(missing_docs)]
#![deny(clippy::future_not_send)]
macro_rules! trace_debug_error {
($result:expr) => {
if let Err(e) = $result {
tracing::debug!("{e}")
}
};
}
mod var_value;
pub use var_value::*;
mod var_any;
pub use var_any::*;
mod var;
pub use var::*;
pub(crate) mod var_impl;
pub use var_impl::*;
pub mod animation;
mod vars;
pub use vars::*;
mod vec;
pub use vec::*;
mod impls;
pub(crate) mod future;
#[macro_export]
macro_rules! impl_from_and_into_var {
($($tt:tt)+) => {
$crate::__impl_from_and_into_var! { $($tt)* }
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_from_and_into_var {
(
$(#[$docs:meta])*
fn from ( $($input:tt)+ )
$($rest:tt)+
) => {
$crate::__impl_from_and_into_var! {
=input=>
[
input { $($input)+ }
generics { }
docs { $(#[$docs])* }
]
( $($input)+ ) $($rest)+
}
};
(
$(#[$docs:meta])*
fn from <
$($rest:tt)+
) => {
$crate::__impl_from_and_into_var! {
=generics=>
[
generics { < }
docs { $(#[$docs])* }
]
$($rest)+
}
};
(
=generics=>
[
generics { $($generics:tt)+ }
$($config:tt)*
]
>( $($input:tt)+ ) $($rest:tt)+
) => {
$crate::__impl_from_and_into_var! {
=input=>
[
input { $($input)+ }
generics { $($generics)+ > }
$($config)*
]
( $($input)+ ) $($rest)+
}
};
(
=generics=>
[
generics { $($generics:tt)+ }
$($config:tt)*
]
>>( $($input:tt)+ ) $($rest:tt)+
) => {
$crate::__impl_from_and_into_var! {
=input=>
[
input { $($input)+ }
generics { $($generics)+ >> }
$($config)*
]
( $($input)+ ) $($rest)+
}
};
(
=generics=>
[
generics { $($generics:tt)+ }
$($config:tt)*
]
$tt:tt $($rest:tt)+
) => {
$crate::__impl_from_and_into_var! {
=generics=>
[
generics { $($generics)+ $tt }
$($config)*
]
$($rest)*
}
};
(
=input=>
[$($config:tt)*]
($ident:ident : $Input:ty $(,)?) $($rest:tt)+
) => {
$crate::__impl_from_and_into_var! {
=output=>
[
input_type { $Input }
$($config)*
]
$($rest)+
}
};
(
=input=>
[$($config:tt)*]
(( $($destructure:tt)+ ) : $Input:ty $(,)?) $($rest:tt)+
) => {
$crate::__impl_from_and_into_var! {
=output=>
[
input_type { $Input }
$($config)*
]
$($rest)+
}
};
(
=input=>
[$($config:tt)*]
([ $($destructure:tt)+ ] : $Input:ty $(,)?) $($rest:tt)+
) => {
$crate::__impl_from_and_into_var! {
=output=>
[
input_type { $Input }
$($config)*
]
$($rest)+
}
};
(
=output=>
[
input_type { $Input:ty }
input { $($input:tt)+ }
generics { $($generics:tt)* }
docs { $($docs:tt)* }
]
-> $Output:ty
;
$($rest:tt)*
) => {
impl $($generics)* $crate::IntoVar<$Output> for $Input {
$($docs)*
fn into_var(self) -> $crate::Var<$Output> {
$crate::IntoVar::into_var(<$Output as From<$Input>>::from(self))
}
}
impl $($generics)* $crate::IntoValue<$Output> for $Input { }
$crate::__impl_from_and_into_var! {
$($rest)*
}
};
(
=output=>
[
input_type { $Input:ty }
input { $($input:tt)+ }
generics { $($generics:tt)* }
docs { $($docs:tt)* }
]
-> $Output:ty
$convert:block
$($rest:tt)*
) => {
impl $($generics)* From<$Input> for $Output {
$($docs)*
fn from($($input)+) -> Self
$convert
}
impl $($generics)* $crate::IntoVar<$Output> for $Input {
$($docs)*
fn into_var(self) -> $crate::Var<$Output> {
$crate::IntoVar::into_var(<$Output as From<$Input>>::from(self))
}
}
impl $($generics)* $crate::IntoValue<$Output> for $Input { }
$crate::__impl_from_and_into_var! {
$($rest)*
}
};
() => {
};
}