diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-05-17 14:41:46 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-05-17 14:41:46 +0200 |
| commit | 551ea99d05166b0be50792f767ddd38b996e32fa (patch) | |
| tree | ec5e86a087e79e8c181c7d4b904216a775227e2d /src/eval | |
| parent | 46aace78ac4ac1c075b9b1670dbb7372df1a0a82 (diff) | |
Show default values in documentation
Fixes #169
Fixes #1102
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/cast.rs | 6 | ||||
| -rw-r--r-- | src/eval/func.rs | 2 | ||||
| -rw-r--r-- | src/eval/value.rs | 2 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/eval/cast.rs b/src/eval/cast.rs index b85d6e76..7ef2f1d0 100644 --- a/src/eval/cast.rs +++ b/src/eval/cast.rs @@ -230,6 +230,12 @@ impl<T: Cast> Cast for Option<T> { } } +impl<T: Into<Value>> From<Spanned<T>> for Value { + fn from(spanned: Spanned<T>) -> Self { + spanned.v.into() + } +} + impl<T: Into<Value>> From<Option<T>> for Value { fn from(v: Option<T>) -> Self { match v { diff --git a/src/eval/func.rs b/src/eval/func.rs index 75231fc9..a224c5b8 100644 --- a/src/eval/func.rs +++ b/src/eval/func.rs @@ -279,6 +279,8 @@ pub struct ParamInfo { pub docs: &'static str, /// Valid values for the parameter. pub cast: CastInfo, + /// Creates an instance of the parameter's default value. + pub default: Option<fn() -> Value>, /// Is the parameter positional? pub positional: bool, /// Is the parameter named? diff --git a/src/eval/value.rs b/src/eval/value.rs index bd612cce..36cda80b 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -54,7 +54,7 @@ pub enum Value { Styles(Styles), /// An array of values: `(1, "hi", 12cm)`. Array(Array), - /// A dictionary value: `(color: #f79143, pattern: dashed)`. + /// A dictionary value: `(a: 1, b: "hi")`. Dict(Dict), /// An executable function. Func(Func), |
