compose_library/foundations/cast/
into_value.rs

1use compose_library::Value;
2
3pub trait IntoValue {
4    fn into_value(self) -> Value;
5}
6
7impl IntoValue for Value {
8    fn into_value(self) -> Value {
9        self
10    }
11}
12
13impl<T: IntoValue> IntoValue for fn() -> T {
14    fn into_value(self) -> Value {
15        self().into_value()
16    }
17}
18
19impl<T: IntoValue> IntoValue for Option<T> {
20    fn into_value(self) -> Value {
21        self.map(IntoValue::into_value).unwrap_or(Value::unit())
22    }
23}