waterui_core/components/
mod.rs

1//! Core Components
2//!
3//! This module provides the fundamental UI components used throughout the application.
4//! It includes various view types and utilities for building user interfaces.
5//!
6//! ## Core View Types
7//!
8//! - `AnyView`: Type-erased view for heterogeneous collections
9//! - `Native`: Platform-specific native UI elements
10//! - `Dynamic`: Runtime-configurable views
11//!
12//! ## Metadata
13//!
14//! The module also provides facilities for attaching metadata to views.
15pub mod anyview;
16pub mod dynamic;
17mod label;
18pub use dynamic::Dynamic;
19pub mod metadata;
20pub use metadata::{IgnorableMetadata, Metadata, Retain};
21pub mod native;
22use crate::View;
23pub use native::{Native, NativeView};
24
25/// A wrapper allows a view to carry an additional value without affecting its rendering.
26#[derive(Debug, Clone)]
27pub struct With<V, T> {
28    view: V,
29    #[allow(unused)]
30    value: T,
31}
32
33impl<V: View, T: 'static> View for With<V, T> {
34    fn body(self, _env: &crate::Environment) -> impl View {
35        self.view
36    }
37}
38
39impl<V, T> With<V, T> {
40    /// Creates a new `With` instance that wraps a view and an additional value.
41    pub const fn new(view: V, value: T) -> Self {
42        Self { view, value }
43    }
44}