diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-12-15 22:51:55 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-12-15 23:11:20 +0100 |
| commit | b6202b646a0d5ecced301d9bac8bfcaf977d7ee4 (patch) | |
| tree | 7d42cb50f9e66153e7e8b2217009684e25f54f42 /library/src/basics/table.rs | |
| parent | f3980c704544a464f9729cc8bc9f97d3a7454769 (diff) | |
Reflection for castables
Diffstat (limited to 'library/src/basics/table.rs')
| -rw-r--r-- | library/src/basics/table.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/library/src/basics/table.rs b/library/src/basics/table.rs index 5a4e8e81..10a9143f 100644 --- a/library/src/basics/table.rs +++ b/library/src/basics/table.rs @@ -2,6 +2,8 @@ use crate::layout::{GridNode, TrackSizing, TrackSizings}; use crate::prelude::*; /// A table of items. +/// +/// Tags: basics. #[func] #[capable(Layout)] #[derive(Debug, Hash)] @@ -125,9 +127,12 @@ impl<T: Cast> Cast<Spanned<Value>> for Celled<T> { fn cast(value: Spanned<Value>) -> StrResult<Self> { match value.v { Value::Func(v) => Ok(Self::Func(v, value.span)), - v => T::cast(v) - .map(Self::Value) - .map_err(|msg| with_alternative(msg, "function")), + v if T::is(&v) => Ok(Self::Value(T::cast(v)?)), + v => Self::error(v), } } + + fn describe() -> CastInfo { + T::describe() + CastInfo::Type("function") + } } |
