please rust analyzer with macros

This commit is contained in:
2025-08-16 02:34:44 -04:00
parent 166394d8d9
commit b0fe7310eb
5 changed files with 45 additions and 32 deletions

View File

@@ -1,28 +1,28 @@
use super::*;
use crate::{UiRegion, Vec2, WidgetArrLike, WidgetFn, WidgetLike};
use crate::{UiRegion, Vec2, WidgetArrLike, WidgetFnRet, WidgetLike};
pub trait CoreWidget<W: 'static, Ctx: 'static, Tag> {
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Regioned, Ctx>;
fn center(self, size: impl Into<Vec2>) -> impl WidgetFn<Regioned, Ctx>;
fn region(self, region: UiRegion) -> impl WidgetFn<Regioned, Ctx>;
fn pad(self, padding: impl Into<Padding>) -> WidgetFnRet!(Regioned, Ctx);
fn center(self, size: impl Into<Vec2>) -> WidgetFnRet!(Regioned, Ctx);
fn region(self, region: UiRegion) -> WidgetFnRet!(Regioned, Ctx);
}
impl<W: WidgetLike<Ctx, Tag>, Ctx: 'static, Tag> CoreWidget<W::Widget, Ctx, Tag> for W {
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Regioned, Ctx> {
fn pad(self, padding: impl Into<Padding>) -> WidgetFnRet!(Regioned, Ctx) {
|ui| Regioned {
region: padding.into().region(),
inner: self.add(ui).erase_type(),
}
}
fn center(self, size: impl Into<Vec2>) -> impl WidgetFn<Regioned, Ctx> {
fn center(self, size: impl Into<Vec2>) -> WidgetFnRet!(Regioned, Ctx) {
|ui| Regioned {
region: UiRegion::center().size(size.into()),
inner: self.add(ui).erase_type(),
}
}
fn region(self, region: UiRegion) -> impl WidgetFn<Regioned, Ctx> {
fn region(self, region: UiRegion) -> WidgetFnRet!(Regioned, Ctx) {
move |ui| Regioned {
region,
inner: self.add(ui).erase_type(),
@@ -31,21 +31,21 @@ impl<W: WidgetLike<Ctx, Tag>, Ctx: 'static, Tag> CoreWidget<W::Widget, Ctx, Tag>
}
pub trait CoreWidgetArr<const LEN: usize, Ctx: 'static, Tag> {
fn span(self, dir: Dir, lengths: [impl Into<SpanLen>; LEN]) -> impl WidgetFn<Span, Ctx>;
fn stack(self) -> impl WidgetFn<Stack, Ctx>;
fn span(self, dir: Dir, lengths: [impl Into<SpanLen>; LEN]) -> WidgetFnRet!(Span, Ctx);
fn stack(self) -> WidgetFnRet!(Stack, Ctx);
}
impl<const LEN: usize, Wa: WidgetArrLike<LEN, Ctx, Tag>, Ctx: 'static, Tag>
CoreWidgetArr<LEN, Ctx, Tag> for Wa
{
fn span(self, dir: Dir, lengths: [impl Into<SpanLen>; LEN]) -> impl WidgetFn<Span, Ctx> {
fn span(self, dir: Dir, lengths: [impl Into<SpanLen>; LEN]) -> WidgetFnRet!(Span, Ctx) {
let lengths = lengths.map(Into::into);
move |ui| Span {
dir,
children: self.ui(ui).arr.into_iter().zip(lengths).collect(),
}
}
fn stack(self) -> impl WidgetFn<Stack, Ctx> {
fn stack(self) -> WidgetFnRet!(Stack, Ctx) {
move |ui| Stack {
children: self.ui(ui).arr.to_vec(),
}