diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-23 21:55:58 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-23 21:55:58 +0200 |
| commit | 04fb8b288aa7c80607da79db7d085a4820b95a9d (patch) | |
| tree | 7ca96d09d511274ebac298c329d5eef53a290d9c /src/eval/show.rs | |
| parent | 7a2cc3e7d29d16c5cf9b5a93a688e14da93c8662 (diff) | |
Show rules with type ascribed object
Diffstat (limited to 'src/eval/show.rs')
| -rw-r--r-- | src/eval/show.rs | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/eval/show.rs b/src/eval/show.rs index 383497ba..f8d98d52 100644 --- a/src/eval/show.rs +++ b/src/eval/show.rs @@ -3,15 +3,24 @@ use std::fmt::{self, Debug, Formatter}; use std::hash::Hash; use std::sync::Arc; -use super::{Content, StyleChain}; +use super::{Content, Dict, StyleChain}; use crate::diag::TypResult; use crate::util::Prehashed; use crate::Context; /// A node that can be realized given some styles. pub trait Show: 'static { - /// Realize this node in the given styles. - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content>; + /// Encode this node into a dictionary. + fn encode(&self) -> Dict; + + /// Show this node in the given styles and optionally given the realization + /// of a show rule. + fn show( + &self, + ctx: &mut Context, + styles: StyleChain, + realized: Option<Content>, + ) -> TypResult<Content>; /// Convert to a packed show node. fn pack(self) -> ShowNode @@ -42,8 +51,17 @@ impl ShowNode { } impl Show for ShowNode { - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> { - self.0.show(ctx, styles) + fn encode(&self) -> Dict { + self.0.encode() + } + + fn show( + &self, + ctx: &mut Context, + styles: StyleChain, + realized: Option<Content>, + ) -> TypResult<Content> { + self.0.show(ctx, styles, realized) } fn pack(self) -> ShowNode { |
