Trait IntoViewKeyExt

Source
pub trait IntoViewKeyExt<A>: IntoView<A> + Sized {
    // Provided method
    fn key(self, key: impl Into<String>) -> View<A> { ... }
}
Expand description

Allows widget.key("id") instead of widget.into_view().key("id").

§Examples

use ailloli_ui_runtime::component::{IntoViewKeyExt, View};
let view: View<()> = IntoViewKeyExt::key(View::empty(), "item");
assert_eq!(view.key_ref(), Some("item"));

Provided Methods§

Source

fn key(self, key: impl Into<String>) -> View<A>

Converts self, assigns the owned key, and returns the view.

§Examples
use ailloli_ui_runtime::component::{IntoViewKeyExt, View};
let view: View<()> = IntoViewKeyExt::key(View::empty(), String::from("x"));
assert_eq!(view.key_ref(), Some("x"));

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§

Source§

impl<T, A> IntoViewKeyExt<A> for T
where T: IntoView<A>,

Implements the IntoViewKeyExt<A> contract for T where T: IntoView<A>.