pub trait Reflect {
    // Required methods
    fn input() -> CastInfo;
    fn output() -> CastInfo;
    fn castable(value: &Value) -> bool;
    // Provided method
    fn error(found: &Value) -> HintedString { ... }
}Expand description
Determine details of a type.
Type casting works as follows:
- Reflect for Tdescribes the possible Typst values for- T(for documentation and autocomplete).
- IntoValue for Tis for conversion from- T -> Value(infallible)
- FromValue for Tis for conversion from- Value -> T(fallible).
We can’t use TryFrom<Value> due to conflicting impls. We could use
From<T> for Value, but that inverses the impl and leads to tons of
.into() all over the place that become hard to decipher.
Required Methods§
Provided Methods§
Sourcefn error(found: &Value) -> HintedString
 
fn error(found: &Value) -> HintedString
Produce an error message for an unacceptable value type.
ⓘ
assert_eq!(
  <i64 as Reflect>::error(&Value::None),
  "expected integer, found none",
);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.