mirror of
https://github.com/typst/typst
synced 2025-07-27 14:27:56 +08:00
refactor: derive(Cast) for ArtifactKind
This commit is contained in:
parent
e6341c0fe4
commit
2d6e3b6151
@ -1,5 +1,5 @@
|
||||
use ecow::EcoString;
|
||||
use typst_macros::{cast, elem};
|
||||
use typst_macros::{cast, elem, Cast};
|
||||
|
||||
use crate::diag::SourceResult;
|
||||
use crate::engine::Engine;
|
||||
@ -200,7 +200,7 @@ pub struct ArtifactElem {
|
||||
pub body: Content,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Cast)]
|
||||
pub enum ArtifactKind {
|
||||
/// Page header artifacts.
|
||||
Header,
|
||||
@ -213,20 +213,6 @@ pub enum ArtifactKind {
|
||||
Other,
|
||||
}
|
||||
|
||||
cast! {
|
||||
ArtifactKind,
|
||||
self => match self {
|
||||
ArtifactKind::Header => "header".into_value(),
|
||||
ArtifactKind::Footer => "footer".into_value(),
|
||||
ArtifactKind::Page => "page".into_value(),
|
||||
ArtifactKind::Other => "other".into_value(),
|
||||
},
|
||||
"header" => Self::Header,
|
||||
"footer" => Self::Footer,
|
||||
"page" => Self::Page,
|
||||
"other" => Self::Other,
|
||||
}
|
||||
|
||||
impl Show for Packed<ArtifactElem> {
|
||||
#[typst_macros::time(name = "pdf.artifact", span = self.span())]
|
||||
fn show(&self, _: &mut Engine, _: StyleChain) -> SourceResult<Content> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user