1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! View trait for element tree generation.
//!
//! Views produce element trees via `render(cx)`. `render` runs inside the
//! reactive observer scope every frame, so signal reads subscribe the view
//! observer (Strategy-A whole-view rebuild).
use crateAnyElement;
use crateRenderCx;
/// Trait for types that produce element trees.
///
/// Implement this trait to define reusable UI components.
/// `render()` is called once per frame to produce the element tree.
///
/// # Example
///
/// ```ignore
/// struct HelloView {
/// message: String,
/// }
///
/// impl View for HelloView {
/// fn render(&mut self, _cx: &mut RenderCx) -> AnyElement {
/// Div::new()
/// .child(Text::new(&self.message))
/// .into_any()
/// }
/// }
/// ```
/// Extension trait for converting elements into AnyElement.
///
/// Implemented via `IntoElement`, provides a convenient `.into_any()` method.