react/element/keyed.rs
1/// A NewType style struct which marks the inner element is created with
2///
3/// `Keyed<T>` doesn't need to impl [`Node`](crate::Node)
4/// as it's not necessary to assign keys for direct child nodes.
5///
6/// `Vec<Keyed<T>>` and `Vec<Option<Keyed<T>>>` (and also corresponding slices and arrays)
7/// impl [`Node`](crate::Node)
8/// as long as `T` impl [`IntoElement`],
9/// so that list of keyed elements can be used as child nodes.
10#[derive(Debug, Clone)]
11pub struct Keyed<T>(pub T);
12
13impl<T> Keyed<T> {
14 #[inline]
15 pub fn inner(&self) -> &T {
16 &self.0
17 }
18 #[inline]
19 pub fn into_inner(self) -> T {
20 self.0
21 }
22}
23
24// TODO: Do we need to impl IntoElement and Node for Keyed<T>
25
26// impl<T: IntoElement> IntoElement for Keyed<T> {
27// fn into_element(self) -> crate::Element {
28// self.0.into_element()
29// }
30// }