diff options
| author | bluebear94 <uruwi@protonmail.com> | 2024-05-06 10:11:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-06 14:11:38 +0000 |
| commit | 102e6717e85bbc6a707d16df24f5f3cf660f735d (patch) | |
| tree | 18dc7e57e81dcd682e4b5bd7b1e447002780a731 /crates | |
| parent | f120932bcdc29af318ff641b42c8c13e3f8ac2ae (diff) | |
Transpose `Option` and `Smart` (#4052)
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst/src/model/bibliography.rs | 11 | ||||
| -rw-r--r-- | crates/typst/src/model/outline.rs | 11 |
2 files changed, 8 insertions, 14 deletions
diff --git a/crates/typst/src/model/bibliography.rs b/crates/typst/src/model/bibliography.rs index b7a10b92..9fcaad06 100644 --- a/crates/typst/src/model/bibliography.rs +++ b/crates/typst/src/model/bibliography.rs @@ -105,8 +105,7 @@ pub struct BibliographyElem { /// The bibliography's heading will not be numbered by default, but you can /// force it to be with a show-set rule: /// `{show bibliography: set heading(numbering: "1.")}` - #[default(Some(Smart::Auto))] - pub title: Option<Smart<Content>>, + pub title: Smart<Option<Content>>, /// Whether to include all works from the given bibliography files, even /// those that weren't cited in the document. @@ -213,11 +212,9 @@ impl Show for Packed<BibliographyElem> { const INDENT: Em = Em::new(1.5); let mut seq = vec![]; - if let Some(title) = self.title(styles) { - let title = title.unwrap_or_else(|| { - TextElem::packed(Self::local_name_in(styles)).spanned(self.span()) - }); - + if let Some(title) = self.title(styles).unwrap_or_else(|| { + Some(TextElem::packed(Self::local_name_in(styles)).spanned(self.span())) + }) { seq.push( HeadingElem::new(title) .with_level(Smart::Custom(NonZeroUsize::ONE)) diff --git a/crates/typst/src/model/outline.rs b/crates/typst/src/model/outline.rs index e9230656..2cf574ce 100644 --- a/crates/typst/src/model/outline.rs +++ b/crates/typst/src/model/outline.rs @@ -73,8 +73,7 @@ pub struct OutlineElem { /// The outline's heading will not be numbered by default, but you can /// force it to be with a show-set rule: /// `{show outline: set heading(numbering: "1.")}` - #[default(Some(Smart::Auto))] - pub title: Option<Smart<Content>>, + pub title: Smart<Option<Content>>, /// The type of element to include in the outline. /// @@ -193,11 +192,9 @@ impl Show for Packed<OutlineElem> { fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> { let mut seq = vec![ParbreakElem::new().pack()]; // Build the outline title. - if let Some(title) = self.title(styles) { - let title = title.unwrap_or_else(|| { - TextElem::packed(Self::local_name_in(styles)).spanned(self.span()) - }); - + if let Some(title) = self.title(styles).unwrap_or_else(|| { + Some(TextElem::packed(Self::local_name_in(styles)).spanned(self.span())) + }) { seq.push( HeadingElem::new(title) .with_depth(NonZeroUsize::ONE) |
