widget fn ret macro
This commit is contained in:
@@ -59,9 +59,17 @@ pub trait WidgetLike {
|
||||
/// A function that returns a widget given a UI.
|
||||
/// Useful for defining trait functions on widgets that create a parent widget so that the children
|
||||
/// don't need to be IDs yet
|
||||
pub trait WFn<W> = FnOnce(&mut Ui) -> W;
|
||||
pub struct WidgetFn<F: FnOnce(&mut Ui) -> W, W>(pub F);
|
||||
pub struct WidgetIdFn<F: FnOnce(&mut Ui) -> WidgetId<W>, W>(pub F);
|
||||
|
||||
macro_rules! WidgetFnRet {
|
||||
($W:ident) => {
|
||||
WidgetFn<impl FnOnce(&mut Ui) -> $W, $W>
|
||||
};
|
||||
}
|
||||
pub(crate) use WidgetFnRet;
|
||||
|
||||
pub trait _WidgetFn<W: Widget> {
|
||||
fn call(ui: &mut Ui) -> W;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user