react/element/
into.rs

1use crate::Element;
2
3pub trait IntoOptionalElement {
4    fn into_optional_element(self) -> Option<Element>;
5}
6
7pub trait IntoElement {
8    fn into_element(self) -> Element;
9}
10
11impl<T: IntoElement> IntoOptionalElement for T {
12    #[inline]
13    fn into_optional_element(self) -> Option<Element> {
14        Some(self.into_element())
15    }
16}
17
18impl IntoElement for Element {
19    #[inline]
20    fn into_element(self) -> Element {
21        self
22    }
23}
24
25impl<T: IntoOptionalElement> IntoOptionalElement for Option<T> {
26    #[inline]
27    fn into_optional_element(self) -> Option<Element> {
28        self.and_then(IntoOptionalElement::into_optional_element)
29    }
30}