summaryrefslogtreecommitdiff
path: root/library/src/meta/reference.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/meta/reference.rs')
-rw-r--r--library/src/meta/reference.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/library/src/meta/reference.rs b/library/src/meta/reference.rs
index c538b696..42450b97 100644
--- a/library/src/meta/reference.rs
+++ b/library/src/meta/reference.rs
@@ -193,7 +193,7 @@ impl Show for RefElem {
Smart::Auto => refable.supplement(),
Smart::Custom(None) => Content::empty(),
Smart::Custom(Some(supplement)) => {
- supplement.resolve(vt, [(*elem).clone().into()])?
+ supplement.resolve(vt, [(*elem).clone()])?
}
};
@@ -229,10 +229,10 @@ pub enum Supplement {
impl Supplement {
/// Tries to resolve the supplement into its content.
- pub fn resolve(
+ pub fn resolve<T: IntoValue>(
&self,
vt: &mut Vt,
- args: impl IntoIterator<Item = Value>,
+ args: impl IntoIterator<Item = T>,
) -> SourceResult<Content> {
Ok(match self {
Supplement::Content(content) => content.clone(),
@@ -241,19 +241,16 @@ impl Supplement {
}
}
-cast_from_value! {
+cast! {
Supplement,
+ self => match self {
+ Self::Content(v) => v.into_value(),
+ Self::Func(v) => v.into_value(),
+ },
v: Content => Self::Content(v),
v: Func => Self::Func(v),
}
-cast_to_value! {
- v: Supplement => match v {
- Supplement::Content(v) => v.into(),
- Supplement::Func(v) => v.into(),
- }
-}
-
/// Marks an element as being able to be referenced. This is used to implement
/// the `@ref` element.
pub trait Refable {