Skip to main content

UiExt

Trait UiExt 

Source
pub trait UiExt: UiPatchTarget + Sized {
    // Provided method
    fn ui(self) -> UiBuilder<Self> { ... }
}
Expand description

Extension trait providing the ui() entrypoint for types that opt into UiPatchTarget.

Most of the ui::* helpers already return a UiBuilder<T>. This trait is primarily useful for:

  • custom patch targets (your own boxes/components),
  • values constructed via inherent constructors that return T (not UiBuilder<T>).
use fret_ui_kit::{ChromeRefinement, LayoutRefinement, UiExt, UiPatch, UiPatchTarget, UiSupportsChrome, UiSupportsLayout};

#[derive(Debug, Default, Clone)]
struct MyBox {
    chrome: ChromeRefinement,
    layout: LayoutRefinement,
}

impl UiPatchTarget for MyBox {
    fn apply_ui_patch(mut self, patch: UiPatch) -> Self {
        self.chrome = self.chrome.merge(patch.chrome);
        self.layout = self.layout.merge(patch.layout);
        self
    }
}

impl UiSupportsChrome for MyBox {}
impl UiSupportsLayout for MyBox {}

let _refined = MyBox::default().ui().px_2().w_full().build();

Provided Methods§

Source

fn ui(self) -> UiBuilder<Self>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§