compose_library/foundations/cast/
into_result.rs1use compose_library::diag::{At, SourceResult, StrResult};
2use compose_library::foundations::cast::into_value::IntoValue;
3use compose_library::Value;
4use compose_syntax::Span;
5
6pub trait IntoResult {
7 fn into_result(self, span: Span) -> SourceResult<Value>;
8}
9
10impl<T: IntoValue> IntoResult for T {
11 fn into_result(self, _: Span) -> SourceResult<Value> {
12 Ok(self.into_value())
13 }
14}
15
16impl<T: IntoValue> IntoResult for StrResult<T> {
17 fn into_result(self, span: Span) -> SourceResult<Value> {
18 self.map(IntoValue::into_value).at(span)
19 }
20}
21
22impl<T: IntoValue> IntoResult for SourceResult<T> {
23 fn into_result(self, _: Span) -> SourceResult<Value> {
24 self.map(IntoValue::into_value)
25 }
26}