use std::fmt;
use crate::prelude::*;
#[macro_export]
macro_rules! callback {
($func:path) => {{ (stringify!($func), $func as _) }};
}
pub struct ViewFn<S: 'static, H: 'static> {
pub(crate) symbol: &'static str,
pub(crate) func: for<'a, 'b> fn(&'a S, &'b mut Ui<S, H>),
}
impl<S, H> Copy for ViewFn<S, H> {}
impl<S, H> Clone for ViewFn<S, H> {
fn clone(&self) -> Self {
*self
}
}
impl<S, H> fmt::Display for ViewFn<S, H> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.symbol)
}
}
impl<S, H> fmt::Debug for ViewFn<S, H> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}()", self.symbol)
}
}
impl<S, H> From<(&'static str, for<'a, 'b> fn(&'a S, &'b mut Ui<S, H>))> for ViewFn<S, H> {
fn from((symbol, func): (&'static str, for<'a, 'b> fn(&'a S, &'b mut Ui<S, H>))) -> Self {
Self { symbol, func }
}
}
pub struct WgpuFn<S: 'static> {
pub(crate) symbol: &'static str,
pub(crate) func: for<'a, 'b, 'c> fn(&'a S, &'b mut WgpuCtx<'c>),
}
impl<S> Copy for WgpuFn<S> {}
impl<S> Clone for WgpuFn<S> {
fn clone(&self) -> Self {
*self
}
}
impl<S> fmt::Display for WgpuFn<S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.symbol)
}
}
impl<S> fmt::Debug for WgpuFn<S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}()", self.symbol)
}
}
impl<S> From<(&'static str, for<'a, 'b, 'c> fn(&'a S, &'b mut WgpuCtx<'c>))> for WgpuFn<S> {
fn from((symbol, func): (&'static str, for<'a, 'b, 'c> fn(&'a S, &'b mut WgpuCtx<'c>))) -> Self {
Self { symbol, func }
}
}