diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-13 16:27:44 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-13 16:27:44 +0200 |
| commit | 05c27a581ece00e27c16be3d9ac69f3eefedcd4b (patch) | |
| tree | ddd1dfb9598d0b629ce90bb963d194dceb0b4b97 /src/eval/mod.rs | |
| parent | 11f1f0818b990be1ed4a16652b7f30bf11159237 (diff) | |
Automatically display value in more places
Diffstat (limited to 'src/eval/mod.rs')
| -rw-r--r-- | src/eval/mod.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs index db50ee82..d39c3c2c 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -354,7 +354,7 @@ fn eval_code( break; } - let tail = to_content(eval_code(ctx, scp, exprs)?).at(span)?; + let tail = eval_code(ctx, scp, exprs)?.display(); Value::Content(tail.styled_with_map(styles)) } Expr::Show(show) => { @@ -364,12 +364,12 @@ fn eval_code( break; } - let tail = to_content(eval_code(ctx, scp, exprs)?).at(span)?; + let tail = eval_code(ctx, scp, exprs)?.display(); Value::Content(tail.styled_with_entry(entry)) } Expr::Wrap(wrap) => { - let tail = to_content(eval_code(ctx, scp, exprs)?).at(span)?; - scp.top.def_mut(wrap.binding().take(), Value::Content(tail)); + let tail = eval_code(ctx, scp, exprs)?; + scp.top.def_mut(wrap.binding().take(), tail); wrap.body().eval(ctx, scp)? } @@ -386,14 +386,6 @@ fn eval_code( Ok(output) } -/// Extract content from a value. -fn to_content(value: Value) -> StrResult<Content> { - let ty = value.type_name(); - value - .cast() - .map_err(|_| format!("expected remaining block to yield content, found {ty}")) -} - impl Eval for ContentBlock { type Output = Content; |
