diff options
| author | Laurenz <laurmaedje@gmail.com> | 2025-01-10 17:54:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-10 16:54:11 +0000 |
| commit | 6b9b78596a6103dfbcadafaeb03eda624da5306a (patch) | |
| tree | 073a9e31f504634290337c20432ea13dc7a8953d /crates/typst-library/src/text | |
| parent | 9473aface183feaf48601c5264c3604f5798169e (diff) | |
Don't generate accessors for required fields (#5680)
Diffstat (limited to 'crates/typst-library/src/text')
| -rw-r--r-- | crates/typst-library/src/text/deco.rs | 8 | ||||
| -rw-r--r-- | crates/typst-library/src/text/mod.rs | 2 | ||||
| -rw-r--r-- | crates/typst-library/src/text/raw.rs | 8 | ||||
| -rw-r--r-- | crates/typst-library/src/text/shift.rs | 8 | ||||
| -rw-r--r-- | crates/typst-library/src/text/smallcaps.rs | 2 |
5 files changed, 14 insertions, 14 deletions
diff --git a/crates/typst-library/src/text/deco.rs b/crates/typst-library/src/text/deco.rs index 5da7ecec..485d0edc 100644 --- a/crates/typst-library/src/text/deco.rs +++ b/crates/typst-library/src/text/deco.rs @@ -81,7 +81,7 @@ pub struct UnderlineElem { impl Show for Packed<UnderlineElem> { #[typst_macros::time(name = "underline", span = self.span())] fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> { - Ok(self.body().clone().styled(TextElem::set_deco(smallvec![Decoration { + Ok(self.body.clone().styled(TextElem::set_deco(smallvec![Decoration { line: DecoLine::Underline { stroke: self.stroke(styles).unwrap_or_default(), offset: self.offset(styles), @@ -173,7 +173,7 @@ pub struct OverlineElem { impl Show for Packed<OverlineElem> { #[typst_macros::time(name = "overline", span = self.span())] fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> { - Ok(self.body().clone().styled(TextElem::set_deco(smallvec![Decoration { + Ok(self.body.clone().styled(TextElem::set_deco(smallvec![Decoration { line: DecoLine::Overline { stroke: self.stroke(styles).unwrap_or_default(), offset: self.offset(styles), @@ -250,7 +250,7 @@ pub struct StrikeElem { impl Show for Packed<StrikeElem> { #[typst_macros::time(name = "strike", span = self.span())] fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> { - Ok(self.body().clone().styled(TextElem::set_deco(smallvec![Decoration { + Ok(self.body.clone().styled(TextElem::set_deco(smallvec![Decoration { // Note that we do not support evade option for strikethrough. line: DecoLine::Strikethrough { stroke: self.stroke(styles).unwrap_or_default(), @@ -345,7 +345,7 @@ pub struct HighlightElem { impl Show for Packed<HighlightElem> { #[typst_macros::time(name = "highlight", span = self.span())] fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> { - Ok(self.body().clone().styled(TextElem::set_deco(smallvec![Decoration { + Ok(self.body.clone().styled(TextElem::set_deco(smallvec![Decoration { line: DecoLine::Highlight { fill: self.fill(styles), stroke: self diff --git a/crates/typst-library/src/text/mod.rs b/crates/typst-library/src/text/mod.rs index d372c399..6cca2458 100644 --- a/crates/typst-library/src/text/mod.rs +++ b/crates/typst-library/src/text/mod.rs @@ -794,7 +794,7 @@ impl Construct for TextElem { impl PlainText for Packed<TextElem> { fn plain_text(&self, text: &mut EcoString) { - text.push_str(self.text()); + text.push_str(&self.text); } } diff --git a/crates/typst-library/src/text/raw.rs b/crates/typst-library/src/text/raw.rs index cd718d2a..01d6d8f0 100644 --- a/crates/typst-library/src/text/raw.rs +++ b/crates/typst-library/src/text/raw.rs @@ -315,7 +315,7 @@ impl Packed<RawElem> { #[comemo::memoize] fn highlight(&self, styles: StyleChain) -> Vec<Packed<RawLine>> { let elem = self.as_ref(); - let lines = preprocess(elem.text(), styles, self.span()); + let lines = preprocess(&elem.text, styles, self.span()); let count = lines.len() as i64; let lang = elem @@ -490,7 +490,7 @@ impl Figurable for Packed<RawElem> {} impl PlainText for Packed<RawElem> { fn plain_text(&self, text: &mut EcoString) { - text.push_str(&self.text().get()); + text.push_str(&self.text.get()); } } @@ -638,13 +638,13 @@ pub struct RawLine { impl Show for Packed<RawLine> { #[typst_macros::time(name = "raw.line", span = self.span())] fn show(&self, _: &mut Engine, _styles: StyleChain) -> SourceResult<Content> { - Ok(self.body().clone()) + Ok(self.body.clone()) } } impl PlainText for Packed<RawLine> { fn plain_text(&self, text: &mut EcoString) { - text.push_str(self.text()); + text.push_str(&self.text); } } diff --git a/crates/typst-library/src/text/shift.rs b/crates/typst-library/src/text/shift.rs index 9723bbf0..3eec0758 100644 --- a/crates/typst-library/src/text/shift.rs +++ b/crates/typst-library/src/text/shift.rs @@ -50,7 +50,7 @@ pub struct SubElem { impl Show for Packed<SubElem> { #[typst_macros::time(name = "sub", span = self.span())] fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> { - let body = self.body().clone(); + let body = self.body.clone(); if self.typographic(styles) { if let Some(text) = convert_script(&body, true) { @@ -109,7 +109,7 @@ pub struct SuperElem { impl Show for Packed<SuperElem> { #[typst_macros::time(name = "super", span = self.span())] fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> { - let body = self.body().clone(); + let body = self.body.clone(); if self.typographic(styles) { if let Some(text) = convert_script(&body, false) { @@ -132,9 +132,9 @@ fn convert_script(content: &Content, sub: bool) -> Option<EcoString> { Some(' '.into()) } else if let Some(elem) = content.to_packed::<TextElem>() { if sub { - elem.text().chars().map(to_subscript_codepoint).collect() + elem.text.chars().map(to_subscript_codepoint).collect() } else { - elem.text().chars().map(to_superscript_codepoint).collect() + elem.text.chars().map(to_superscript_codepoint).collect() } } else if let Some(sequence) = content.to_packed::<SequenceElem>() { sequence diff --git a/crates/typst-library/src/text/smallcaps.rs b/crates/typst-library/src/text/smallcaps.rs index bf003bd1..1e88974f 100644 --- a/crates/typst-library/src/text/smallcaps.rs +++ b/crates/typst-library/src/text/smallcaps.rs @@ -53,6 +53,6 @@ pub struct SmallcapsElem { impl Show for Packed<SmallcapsElem> { #[typst_macros::time(name = "smallcaps", span = self.span())] fn show(&self, _: &mut Engine, _: StyleChain) -> SourceResult<Content> { - Ok(self.body().clone().styled(TextElem::set_smallcaps(true))) + Ok(self.body.clone().styled(TextElem::set_smallcaps(true))) } } |
