mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Don't generate accessors for required fields (#5680)
This commit is contained in:
parent
9473aface1
commit
6b9b78596a
@ -161,9 +161,9 @@ pub fn collect<'a>(
|
||||
}
|
||||
|
||||
if let Some(case) = TextElem::case_in(styles) {
|
||||
full.push_str(&case.apply(elem.text()));
|
||||
full.push_str(&case.apply(&elem.text));
|
||||
} else {
|
||||
full.push_str(elem.text());
|
||||
full.push_str(&elem.text);
|
||||
}
|
||||
|
||||
if dir != outer_dir {
|
||||
@ -172,13 +172,12 @@ pub fn collect<'a>(
|
||||
}
|
||||
});
|
||||
} else if let Some(elem) = child.to_packed::<HElem>() {
|
||||
let amount = elem.amount();
|
||||
if amount.is_zero() {
|
||||
if elem.amount.is_zero() {
|
||||
continue;
|
||||
}
|
||||
|
||||
collector.push_item(match amount {
|
||||
Spacing::Fr(fr) => Item::Fractional(*fr, None),
|
||||
collector.push_item(match elem.amount {
|
||||
Spacing::Fr(fr) => Item::Fractional(fr, None),
|
||||
Spacing::Rel(rel) => Item::Absolute(
|
||||
rel.resolve(styles).relative_to(region.x),
|
||||
elem.weak(styles),
|
||||
|
@ -40,7 +40,7 @@ pub fn layout_list(
|
||||
let mut cells = vec![];
|
||||
let mut locator = locator.split();
|
||||
|
||||
for item in elem.children() {
|
||||
for item in &elem.children {
|
||||
cells.push(Cell::new(Content::empty(), locator.next(&())));
|
||||
cells.push(Cell::new(marker.clone(), locator.next(&marker.span())));
|
||||
cells.push(Cell::new(Content::empty(), locator.next(&())));
|
||||
@ -101,7 +101,7 @@ pub fn layout_enum(
|
||||
// relation to the item it refers to.
|
||||
let number_align = elem.number_align(styles);
|
||||
|
||||
for item in elem.children() {
|
||||
for item in &elem.children {
|
||||
number = item.number(styles).unwrap_or(number);
|
||||
|
||||
let context = Context::new(None, Some(styles));
|
||||
|
@ -16,7 +16,7 @@ pub fn layout_accent(
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let cramped = style_cramped();
|
||||
let mut base = ctx.layout_into_fragment(elem.base(), styles.chain(&cramped))?;
|
||||
let mut base = ctx.layout_into_fragment(&elem.base, styles.chain(&cramped))?;
|
||||
|
||||
// Try to replace a glyph with its dotless variant.
|
||||
if let MathFragment::Glyph(glyph) = &mut base {
|
||||
@ -29,8 +29,8 @@ pub fn layout_accent(
|
||||
|
||||
let width = elem.size(styles).relative_to(base.width());
|
||||
|
||||
let Accent(c) = elem.accent();
|
||||
let mut glyph = GlyphFragment::new(ctx, styles, *c, elem.span());
|
||||
let Accent(c) = elem.accent;
|
||||
let mut glyph = GlyphFragment::new(ctx, styles, c, elem.span());
|
||||
|
||||
// Try to replace accent glyph with flattened variant.
|
||||
let flattened_base_height = scaled!(ctx, styles, flattened_accent_base_height);
|
||||
|
@ -29,7 +29,7 @@ pub fn layout_attach(
|
||||
let elem = merged.as_ref().unwrap_or(elem);
|
||||
let stretch = stretch_size(styles, elem);
|
||||
|
||||
let mut base = ctx.layout_into_fragment(elem.base(), styles)?;
|
||||
let mut base = ctx.layout_into_fragment(&elem.base, styles)?;
|
||||
let sup_style = style_for_superscript(styles);
|
||||
let sup_style_chain = styles.chain(&sup_style);
|
||||
let tl = elem.tl(sup_style_chain);
|
||||
@ -95,7 +95,7 @@ pub fn layout_primes(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
match *elem.count() {
|
||||
match elem.count {
|
||||
count @ 1..=4 => {
|
||||
let c = match count {
|
||||
1 => '′',
|
||||
@ -134,7 +134,7 @@ pub fn layout_scripts(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let mut fragment = ctx.layout_into_fragment(elem.body(), styles)?;
|
||||
let mut fragment = ctx.layout_into_fragment(&elem.body, styles)?;
|
||||
fragment.set_limits(Limits::Never);
|
||||
ctx.push(fragment);
|
||||
Ok(())
|
||||
@ -148,7 +148,7 @@ pub fn layout_limits(
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let limits = if elem.inline(styles) { Limits::Always } else { Limits::Display };
|
||||
let mut fragment = ctx.layout_into_fragment(elem.body(), styles)?;
|
||||
let mut fragment = ctx.layout_into_fragment(&elem.body, styles)?;
|
||||
fragment.set_limits(limits);
|
||||
ctx.push(fragment);
|
||||
Ok(())
|
||||
@ -157,9 +157,9 @@ pub fn layout_limits(
|
||||
/// Get the size to stretch the base to.
|
||||
fn stretch_size(styles: StyleChain, elem: &Packed<AttachElem>) -> Option<Rel<Abs>> {
|
||||
// Extract from an EquationElem.
|
||||
let mut base = elem.base();
|
||||
let mut base = &elem.base;
|
||||
while let Some(equation) = base.to_packed::<EquationElem>() {
|
||||
base = equation.body();
|
||||
base = &equation.body;
|
||||
}
|
||||
|
||||
base.to_packed::<StretchElem>().map(|stretch| stretch.size(styles))
|
||||
|
@ -16,7 +16,7 @@ pub fn layout_cancel(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let body = ctx.layout_into_fragment(elem.body(), styles)?;
|
||||
let body = ctx.layout_into_fragment(&elem.body, styles)?;
|
||||
|
||||
// Preserve properties of body.
|
||||
let body_class = body.class();
|
||||
|
@ -23,8 +23,8 @@ pub fn layout_frac(
|
||||
layout_frac_like(
|
||||
ctx,
|
||||
styles,
|
||||
elem.num(),
|
||||
std::slice::from_ref(elem.denom()),
|
||||
&elem.num,
|
||||
std::slice::from_ref(&elem.denom),
|
||||
false,
|
||||
elem.span(),
|
||||
)
|
||||
@ -37,7 +37,7 @@ pub fn layout_binom(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
layout_frac_like(ctx, styles, elem.upper(), elem.lower(), true, elem.span())
|
||||
layout_frac_like(ctx, styles, &elem.upper, &elem.lower, true, elem.span())
|
||||
}
|
||||
|
||||
/// Layout a fraction or binomial.
|
||||
|
@ -13,17 +13,16 @@ pub fn layout_lr(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let mut body = elem.body();
|
||||
|
||||
// Extract from an EquationElem.
|
||||
let mut body = &elem.body;
|
||||
if let Some(equation) = body.to_packed::<EquationElem>() {
|
||||
body = equation.body();
|
||||
body = &equation.body;
|
||||
}
|
||||
|
||||
// Extract implicit LrElem.
|
||||
if let Some(lr) = body.to_packed::<LrElem>() {
|
||||
if lr.size(styles).is_one() {
|
||||
body = lr.body();
|
||||
body = &lr.body;
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +99,7 @@ pub fn layout_mid(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let mut fragments = ctx.layout_into_fragments(elem.body(), styles)?;
|
||||
let mut fragments = ctx.layout_into_fragments(&elem.body, styles)?;
|
||||
|
||||
for fragment in &mut fragments {
|
||||
match fragment {
|
||||
|
@ -27,7 +27,7 @@ pub fn layout_vec(
|
||||
let frame = layout_vec_body(
|
||||
ctx,
|
||||
styles,
|
||||
elem.children(),
|
||||
&elem.children,
|
||||
elem.align(styles),
|
||||
elem.gap(styles),
|
||||
LeftRightAlternator::Right,
|
||||
@ -44,7 +44,7 @@ pub fn layout_mat(
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let augment = elem.augment(styles);
|
||||
let rows = elem.rows();
|
||||
let rows = &elem.rows;
|
||||
|
||||
if let Some(aug) = &augment {
|
||||
for &offset in &aug.hline.0 {
|
||||
@ -58,7 +58,7 @@ pub fn layout_mat(
|
||||
}
|
||||
}
|
||||
|
||||
let ncols = elem.rows().first().map_or(0, |row| row.len());
|
||||
let ncols = rows.first().map_or(0, |row| row.len());
|
||||
|
||||
for &offset in &aug.vline.0 {
|
||||
if offset == 0 || offset.unsigned_abs() >= ncols {
|
||||
@ -97,7 +97,7 @@ pub fn layout_cases(
|
||||
let frame = layout_vec_body(
|
||||
ctx,
|
||||
styles,
|
||||
elem.children(),
|
||||
&elem.children,
|
||||
FixedAlignment::Start,
|
||||
elem.gap(styles),
|
||||
LeftRightAlternator::None,
|
||||
|
@ -632,7 +632,7 @@ fn layout_h(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
if let Spacing::Rel(rel) = elem.amount() {
|
||||
if let Spacing::Rel(rel) = elem.amount {
|
||||
if rel.rel.is_zero() {
|
||||
ctx.push(MathFragment::Spacing(rel.abs.resolve(styles), elem.weak(styles)));
|
||||
}
|
||||
@ -647,11 +647,10 @@ fn layout_class(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let class = *elem.class();
|
||||
let style = EquationElem::set_class(Some(class)).wrap();
|
||||
let mut fragment = ctx.layout_into_fragment(elem.body(), styles.chain(&style))?;
|
||||
fragment.set_class(class);
|
||||
fragment.set_limits(Limits::for_class(class));
|
||||
let style = EquationElem::set_class(Some(elem.class)).wrap();
|
||||
let mut fragment = ctx.layout_into_fragment(&elem.body, styles.chain(&style))?;
|
||||
fragment.set_class(elem.class);
|
||||
fragment.set_limits(Limits::for_class(elem.class));
|
||||
ctx.push(fragment);
|
||||
Ok(())
|
||||
}
|
||||
@ -663,7 +662,7 @@ fn layout_op(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let fragment = ctx.layout_into_fragment(elem.text(), styles)?;
|
||||
let fragment = ctx.layout_into_fragment(&elem.text, styles)?;
|
||||
let italics = fragment.italics_correction();
|
||||
let accent_attach = fragment.accent_attach();
|
||||
let text_like = fragment.is_text_like();
|
||||
|
@ -18,7 +18,6 @@ pub fn layout_root(
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let index = elem.index(styles);
|
||||
let radicand = elem.radicand();
|
||||
let span = elem.span();
|
||||
|
||||
let gap = scaled!(
|
||||
@ -36,7 +35,7 @@ pub fn layout_root(
|
||||
let radicand = {
|
||||
let cramped = style_cramped();
|
||||
let styles = styles.chain(&cramped);
|
||||
let run = ctx.layout_into_run(radicand, styles)?;
|
||||
let run = ctx.layout_into_run(&elem.radicand, styles)?;
|
||||
let multiline = run.is_multiline();
|
||||
let mut radicand = run.into_fragment(styles).into_frame();
|
||||
if multiline {
|
||||
|
@ -21,7 +21,7 @@ pub fn layout_stretch(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let mut fragment = ctx.layout_into_fragment(elem.body(), styles)?;
|
||||
let mut fragment = ctx.layout_into_fragment(&elem.body, styles)?;
|
||||
stretch_fragment(
|
||||
ctx,
|
||||
styles,
|
||||
|
@ -20,7 +20,7 @@ pub fn layout_text(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
let text = elem.text();
|
||||
let text = &elem.text;
|
||||
let span = elem.span();
|
||||
let mut chars = text.chars();
|
||||
let math_size = EquationElem::size_in(styles);
|
||||
|
@ -32,7 +32,7 @@ pub fn layout_underline(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
layout_underoverline(ctx, styles, elem.body(), elem.span(), Position::Under)
|
||||
layout_underoverline(ctx, styles, &elem.body, elem.span(), Position::Under)
|
||||
}
|
||||
|
||||
/// Lays out an [`OverlineElem`].
|
||||
@ -42,7 +42,7 @@ pub fn layout_overline(
|
||||
ctx: &mut MathContext,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<()> {
|
||||
layout_underoverline(ctx, styles, elem.body(), elem.span(), Position::Over)
|
||||
layout_underoverline(ctx, styles, &elem.body, elem.span(), Position::Over)
|
||||
}
|
||||
|
||||
/// Lays out an [`UnderbraceElem`].
|
||||
@ -55,7 +55,7 @@ pub fn layout_underbrace(
|
||||
layout_underoverspreader(
|
||||
ctx,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
&elem.annotation(styles),
|
||||
'⏟',
|
||||
BRACE_GAP,
|
||||
@ -74,7 +74,7 @@ pub fn layout_overbrace(
|
||||
layout_underoverspreader(
|
||||
ctx,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
&elem.annotation(styles),
|
||||
'⏞',
|
||||
BRACE_GAP,
|
||||
@ -93,7 +93,7 @@ pub fn layout_underbracket(
|
||||
layout_underoverspreader(
|
||||
ctx,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
&elem.annotation(styles),
|
||||
'⎵',
|
||||
BRACKET_GAP,
|
||||
@ -112,7 +112,7 @@ pub fn layout_overbracket(
|
||||
layout_underoverspreader(
|
||||
ctx,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
&elem.annotation(styles),
|
||||
'⎴',
|
||||
BRACKET_GAP,
|
||||
@ -131,7 +131,7 @@ pub fn layout_underparen(
|
||||
layout_underoverspreader(
|
||||
ctx,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
&elem.annotation(styles),
|
||||
'⏝',
|
||||
PAREN_GAP,
|
||||
@ -150,7 +150,7 @@ pub fn layout_overparen(
|
||||
layout_underoverspreader(
|
||||
ctx,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
&elem.annotation(styles),
|
||||
'⏜',
|
||||
PAREN_GAP,
|
||||
@ -169,7 +169,7 @@ pub fn layout_undershell(
|
||||
layout_underoverspreader(
|
||||
ctx,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
&elem.annotation(styles),
|
||||
'⏡',
|
||||
SHELL_GAP,
|
||||
@ -188,7 +188,7 @@ pub fn layout_overshell(
|
||||
layout_underoverspreader(
|
||||
ctx,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
&elem.annotation(styles),
|
||||
'⏠',
|
||||
SHELL_GAP,
|
||||
|
@ -62,7 +62,7 @@ pub fn layout_path(
|
||||
axes.resolve(styles).zip_map(region.size, Rel::relative_to).to_point()
|
||||
};
|
||||
|
||||
let vertices = elem.vertices();
|
||||
let vertices = &elem.vertices;
|
||||
let points: Vec<Point> = vertices.iter().map(|c| resolve(c.vertex())).collect();
|
||||
|
||||
let mut size = Size::zero();
|
||||
@ -150,7 +150,7 @@ pub fn layout_curve(
|
||||
) -> SourceResult<Frame> {
|
||||
let mut builder = CurveBuilder::new(region, styles);
|
||||
|
||||
for item in elem.components() {
|
||||
for item in &elem.components {
|
||||
match item {
|
||||
CurveComponent::Move(element) => {
|
||||
let relative = element.relative(styles);
|
||||
@ -399,7 +399,7 @@ pub fn layout_polygon(
|
||||
region: Region,
|
||||
) -> SourceResult<Frame> {
|
||||
let points: Vec<Point> = elem
|
||||
.vertices()
|
||||
.vertices
|
||||
.iter()
|
||||
.map(|c| c.resolve(styles).zip_map(region.size, Rel::relative_to).to_point())
|
||||
.collect();
|
||||
|
@ -27,7 +27,7 @@ pub fn layout_stack(
|
||||
let spacing = elem.spacing(styles);
|
||||
let mut deferred = None;
|
||||
|
||||
for child in elem.children() {
|
||||
for child in &elem.children {
|
||||
match child {
|
||||
StackChild::Spacing(kind) => {
|
||||
layouter.layout_spacing(*kind);
|
||||
@ -36,14 +36,14 @@ pub fn layout_stack(
|
||||
StackChild::Block(block) => {
|
||||
// Transparently handle `h`.
|
||||
if let (Axis::X, Some(h)) = (axis, block.to_packed::<HElem>()) {
|
||||
layouter.layout_spacing(*h.amount());
|
||||
layouter.layout_spacing(h.amount);
|
||||
deferred = None;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Transparently handle `v`.
|
||||
if let (Axis::Y, Some(v)) = (axis, block.to_packed::<VElem>()) {
|
||||
layouter.layout_spacing(*v.amount());
|
||||
layouter.layout_spacing(v.amount);
|
||||
deferred = None;
|
||||
continue;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ pub fn layout_rotate(
|
||||
region,
|
||||
size,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
Transform::rotate(angle),
|
||||
align,
|
||||
elem.reflow(styles),
|
||||
@ -81,7 +81,7 @@ pub fn layout_scale(
|
||||
region,
|
||||
size,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
Transform::scale(scale.x, scale.y),
|
||||
elem.origin(styles).resolve(styles),
|
||||
elem.reflow(styles),
|
||||
@ -169,7 +169,7 @@ pub fn layout_skew(
|
||||
region,
|
||||
size,
|
||||
styles,
|
||||
elem.body(),
|
||||
&elem.body,
|
||||
Transform::skew(ax, ay),
|
||||
align,
|
||||
elem.reflow(styles),
|
||||
|
@ -800,7 +800,7 @@ impl ManualPageCounter {
|
||||
let Some(elem) = elem.to_packed::<CounterUpdateElem>() else {
|
||||
continue;
|
||||
};
|
||||
if *elem.key() == CounterKey::Page {
|
||||
if elem.key == CounterKey::Page {
|
||||
let mut state = CounterState(smallvec![self.logical]);
|
||||
state.update(engine, elem.update.clone())?;
|
||||
self.logical = state.first();
|
||||
|
@ -245,7 +245,7 @@ impl State {
|
||||
|
||||
for elem in introspector.query(&self.selector()) {
|
||||
let elem = elem.to_packed::<StateUpdateElem>().unwrap();
|
||||
match elem.update() {
|
||||
match &elem.update {
|
||||
StateUpdate::Set(value) => state = value.clone(),
|
||||
StateUpdate::Func(func) => {
|
||||
state = func.call(&mut engine, Context::none().track(), [state])?
|
||||
|
@ -100,7 +100,7 @@ pub struct AlignElem {
|
||||
impl Show for Packed<AlignElem> {
|
||||
#[typst_macros::time(name = "align", span = self.span())]
|
||||
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
Ok(self.body().clone().aligned(self.alignment(styles)))
|
||||
Ok(self.body.clone().aligned(self.alignment(styles)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ impl Packed<InlineElem> {
|
||||
styles: StyleChain,
|
||||
region: Size,
|
||||
) -> SourceResult<Vec<InlineItem>> {
|
||||
self.body().call(engine, locator, styles, region)
|
||||
self.body.call(engine, locator, styles, region)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -749,7 +749,7 @@ cast! {
|
||||
|
||||
impl Show for Packed<GridCell> {
|
||||
fn show(&self, _engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
show_grid_cell(self.body().clone(), self.inset(styles), self.align(styles))
|
||||
show_grid_cell(self.body.clone(), self.inset(styles), self.align(styles))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,16 +42,16 @@ pub fn grid_to_cellgrid<'a>(
|
||||
// Use trace to link back to the grid when a specific cell errors
|
||||
let tracepoint = || Tracepoint::Call(Some(eco_format!("grid")));
|
||||
let resolve_item = |item: &GridItem| grid_item_to_resolvable(item, styles);
|
||||
let children = elem.children().iter().map(|child| match child {
|
||||
let children = elem.children.iter().map(|child| match child {
|
||||
GridChild::Header(header) => ResolvableGridChild::Header {
|
||||
repeat: header.repeat(styles),
|
||||
span: header.span(),
|
||||
items: header.children().iter().map(resolve_item),
|
||||
items: header.children.iter().map(resolve_item),
|
||||
},
|
||||
GridChild::Footer(footer) => ResolvableGridChild::Footer {
|
||||
repeat: footer.repeat(styles),
|
||||
span: footer.span(),
|
||||
items: footer.children().iter().map(resolve_item),
|
||||
items: footer.children.iter().map(resolve_item),
|
||||
},
|
||||
GridChild::Item(item) => {
|
||||
ResolvableGridChild::Item(grid_item_to_resolvable(item, styles))
|
||||
@ -95,16 +95,16 @@ pub fn table_to_cellgrid<'a>(
|
||||
// Use trace to link back to the table when a specific cell errors
|
||||
let tracepoint = || Tracepoint::Call(Some(eco_format!("table")));
|
||||
let resolve_item = |item: &TableItem| table_item_to_resolvable(item, styles);
|
||||
let children = elem.children().iter().map(|child| match child {
|
||||
let children = elem.children.iter().map(|child| match child {
|
||||
TableChild::Header(header) => ResolvableGridChild::Header {
|
||||
repeat: header.repeat(styles),
|
||||
span: header.span(),
|
||||
items: header.children().iter().map(resolve_item),
|
||||
items: header.children.iter().map(resolve_item),
|
||||
},
|
||||
TableChild::Footer(footer) => ResolvableGridChild::Footer {
|
||||
repeat: footer.repeat(styles),
|
||||
span: footer.span(),
|
||||
items: footer.children().iter().map(resolve_item),
|
||||
items: footer.children.iter().map(resolve_item),
|
||||
},
|
||||
TableChild::Item(item) => {
|
||||
ResolvableGridChild::Item(table_item_to_resolvable(item, styles))
|
||||
|
@ -29,6 +29,6 @@ pub struct HideElem {
|
||||
impl Show for Packed<HideElem> {
|
||||
#[typst_macros::time(name = "hide", span = self.span())]
|
||||
fn show(&self, _: &mut Engine, _: StyleChain) -> SourceResult<Content> {
|
||||
Ok(self.body().clone().styled(HideElem::set_hidden(true)))
|
||||
Ok(self.body.clone().styled(HideElem::set_hidden(true)))
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ impl Show for Packed<LayoutElem> {
|
||||
let loc = elem.location().unwrap();
|
||||
let context = Context::new(Some(loc), Some(styles));
|
||||
let result = elem
|
||||
.func()
|
||||
.func
|
||||
.call(
|
||||
engine,
|
||||
context.track(),
|
||||
|
@ -143,7 +143,7 @@ cast! {
|
||||
self => self.0.into_value(),
|
||||
v: char => Self::new(v),
|
||||
v: Content => match v.to_packed::<TextElem>() {
|
||||
Some(elem) => Value::Str(elem.text().clone().into()).cast()?,
|
||||
Some(elem) => Value::Str(elem.text.clone().into()).cast()?,
|
||||
None => bail!("expected text"),
|
||||
},
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ impl Packed<AttachElem> {
|
||||
/// base AttachElem where possible.
|
||||
pub fn merge_base(&self) -> Option<Self> {
|
||||
// Extract from an EquationElem.
|
||||
let mut base = self.base();
|
||||
let mut base = &self.base;
|
||||
while let Some(equation) = base.to_packed::<EquationElem>() {
|
||||
base = equation.body();
|
||||
base = &equation.body;
|
||||
}
|
||||
|
||||
// Move attachments from elem into base where possible.
|
||||
|
@ -638,7 +638,7 @@ impl<'a> Generator<'a> {
|
||||
for elem in &self.groups {
|
||||
let group = elem.to_packed::<CiteGroup>().unwrap();
|
||||
let location = elem.location().unwrap();
|
||||
let children = group.children();
|
||||
let children = &group.children;
|
||||
|
||||
// Groups should never be empty.
|
||||
let Some(first) = children.first() else { continue };
|
||||
@ -650,12 +650,11 @@ impl<'a> Generator<'a> {
|
||||
|
||||
// Create infos and items for each child in the group.
|
||||
for child in children {
|
||||
let key = *child.key();
|
||||
let Some(entry) = database.get(key) else {
|
||||
let Some(entry) = database.get(child.key) else {
|
||||
errors.push(error!(
|
||||
child.span(),
|
||||
"key `{}` does not exist in the bibliography",
|
||||
key.resolve()
|
||||
child.key.resolve()
|
||||
));
|
||||
continue;
|
||||
};
|
||||
@ -682,7 +681,7 @@ impl<'a> Generator<'a> {
|
||||
};
|
||||
|
||||
normal &= special_form.is_none();
|
||||
subinfos.push(CiteInfo { key, supplement, hidden });
|
||||
subinfos.push(CiteInfo { key: child.key, supplement, hidden });
|
||||
items.push(CitationItem::new(entry, locator, None, hidden, special_form));
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ impl Synthesize for Packed<FigureElem> {
|
||||
|
||||
// Determine the figure's kind.
|
||||
let kind = elem.kind(styles).unwrap_or_else(|| {
|
||||
elem.body()
|
||||
elem.body
|
||||
.query_first(&Selector::can::<dyn Figurable>())
|
||||
.map(|elem| FigureKind::Elem(elem.func()))
|
||||
.unwrap_or_else(|| FigureKind::Elem(ImageElem::elem()))
|
||||
@ -288,14 +288,13 @@ impl Synthesize for Packed<FigureElem> {
|
||||
// Resolve the supplement with the first descendant of the kind or
|
||||
// just the body, if none was found.
|
||||
let descendant = match kind {
|
||||
FigureKind::Elem(func) => elem
|
||||
.body()
|
||||
.query_first(&Selector::Elem(func, None))
|
||||
.map(Cow::Owned),
|
||||
FigureKind::Elem(func) => {
|
||||
elem.body.query_first(&Selector::Elem(func, None)).map(Cow::Owned)
|
||||
}
|
||||
FigureKind::Name(_) => None,
|
||||
};
|
||||
|
||||
let target = descendant.unwrap_or_else(|| Cow::Borrowed(elem.body()));
|
||||
let target = descendant.unwrap_or_else(|| Cow::Borrowed(&elem.body));
|
||||
Some(supplement.resolve(engine, styles, [target])?)
|
||||
}
|
||||
};
|
||||
@ -437,7 +436,7 @@ impl Outlinable for Packed<FigureElem> {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let mut realized = caption.body().clone();
|
||||
let mut realized = caption.body.clone();
|
||||
if let (
|
||||
Smart::Custom(Some(Supplement::Content(mut supplement))),
|
||||
Some(Some(counter)),
|
||||
@ -460,7 +459,7 @@ impl Outlinable for Packed<FigureElem> {
|
||||
|
||||
let separator = caption.get_separator(StyleChain::default());
|
||||
|
||||
realized = supplement + numbers + separator + caption.body();
|
||||
realized = supplement + numbers + separator + caption.body.clone();
|
||||
}
|
||||
|
||||
Ok(Some(realized))
|
||||
@ -604,7 +603,7 @@ impl Synthesize for Packed<FigureCaption> {
|
||||
impl Show for Packed<FigureCaption> {
|
||||
#[typst_macros::time(name = "figure.caption", span = self.span())]
|
||||
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
let mut realized = self.body().clone();
|
||||
let mut realized = self.body.clone();
|
||||
|
||||
if let (
|
||||
Some(Some(mut supplement)),
|
||||
|
@ -105,12 +105,12 @@ impl FootnoteElem {
|
||||
|
||||
/// Tests if this footnote is a reference to another footnote.
|
||||
pub fn is_ref(&self) -> bool {
|
||||
matches!(self.body(), FootnoteBody::Reference(_))
|
||||
matches!(self.body, FootnoteBody::Reference(_))
|
||||
}
|
||||
|
||||
/// Returns the content of the body of this footnote if it is not a ref.
|
||||
pub fn body_content(&self) -> Option<&Content> {
|
||||
match self.body() {
|
||||
match &self.body {
|
||||
FootnoteBody::Content(content) => Some(content),
|
||||
_ => None,
|
||||
}
|
||||
@ -120,9 +120,9 @@ impl FootnoteElem {
|
||||
impl Packed<FootnoteElem> {
|
||||
/// Returns the location of the definition of this footnote.
|
||||
pub fn declaration_location(&self, engine: &Engine) -> StrResult<Location> {
|
||||
match self.body() {
|
||||
match self.body {
|
||||
FootnoteBody::Reference(label) => {
|
||||
let element = engine.introspector.query_label(*label)?;
|
||||
let element = engine.introspector.query_label(label)?;
|
||||
let footnote = element
|
||||
.to_packed::<FootnoteElem>()
|
||||
.ok_or("referenced element should be a footnote")?;
|
||||
@ -281,12 +281,11 @@ impl Show for Packed<FootnoteEntry> {
|
||||
#[typst_macros::time(name = "footnote.entry", span = self.span())]
|
||||
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
let span = self.span();
|
||||
let note = self.note();
|
||||
let number_gap = Em::new(0.05);
|
||||
let default = StyleChain::default();
|
||||
let numbering = note.numbering(default);
|
||||
let numbering = self.note.numbering(default);
|
||||
let counter = Counter::of(FootnoteElem::elem());
|
||||
let Some(loc) = note.location() else {
|
||||
let Some(loc) = self.note.location() else {
|
||||
bail!(
|
||||
span, "footnote entry must have a location";
|
||||
hint: "try using a query or a show rule to customize the footnote instead"
|
||||
@ -304,7 +303,7 @@ impl Show for Packed<FootnoteEntry> {
|
||||
HElem::new(self.indent(styles).into()).pack(),
|
||||
sup,
|
||||
HElem::new(number_gap.into()).with_weak(true).pack(),
|
||||
note.body_content().unwrap().clone(),
|
||||
self.note.body_content().unwrap().clone(),
|
||||
]))
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ impl Show for Packed<HeadingElem> {
|
||||
const SPACING_TO_NUMBERING: Em = Em::new(0.3);
|
||||
|
||||
let span = self.span();
|
||||
let mut realized = self.body().clone();
|
||||
let mut realized = self.body.clone();
|
||||
|
||||
let hanging_indent = self.hanging_indent(styles);
|
||||
let mut indent = match hanging_indent {
|
||||
@ -360,7 +360,7 @@ impl Outlinable for Packed<HeadingElem> {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let mut content = self.body().clone();
|
||||
let mut content = self.body.clone();
|
||||
if let Some(numbering) = (**self).numbering(StyleChain::default()).as_ref() {
|
||||
let numbers = Counter::of(HeadingElem::elem()).display_at_loc(
|
||||
engine,
|
||||
|
@ -102,11 +102,10 @@ impl LinkElem {
|
||||
impl Show for Packed<LinkElem> {
|
||||
#[typst_macros::time(name = "link", span = self.span())]
|
||||
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
let body = self.body().clone();
|
||||
let dest = self.dest();
|
||||
let body = self.body.clone();
|
||||
|
||||
Ok(if TargetElem::target_in(styles).is_html() {
|
||||
if let LinkTarget::Dest(Destination::Url(url)) = dest {
|
||||
if let LinkTarget::Dest(Destination::Url(url)) = &self.dest {
|
||||
HtmlElem::new(tag::a)
|
||||
.with_attr(attr::href, url.clone().into_inner())
|
||||
.with_body(Some(body))
|
||||
@ -120,7 +119,7 @@ impl Show for Packed<LinkElem> {
|
||||
body
|
||||
}
|
||||
} else {
|
||||
let linked = match self.dest() {
|
||||
let linked = match &self.dest {
|
||||
LinkTarget::Dest(dest) => body.linked(dest.clone()),
|
||||
LinkTarget::Label(label) => {
|
||||
let elem = engine.introspector.query_label(*label).at(self.span())?;
|
||||
|
@ -219,8 +219,7 @@ impl Show for Packed<OutlineElem> {
|
||||
continue;
|
||||
};
|
||||
|
||||
let level = entry.level();
|
||||
if depth < *level {
|
||||
if depth < entry.level {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -229,7 +228,7 @@ impl Show for Packed<OutlineElem> {
|
||||
while ancestors
|
||||
.last()
|
||||
.and_then(|ancestor| ancestor.with::<dyn Outlinable>())
|
||||
.is_some_and(|last| last.level() >= *level)
|
||||
.is_some_and(|last| last.level() >= entry.level)
|
||||
{
|
||||
ancestors.pop();
|
||||
}
|
||||
@ -483,7 +482,7 @@ impl Show for Packed<OutlineEntry> {
|
||||
#[typst_macros::time(name = "outline.entry", span = self.span())]
|
||||
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
let mut seq = vec![];
|
||||
let elem = self.element();
|
||||
let elem = &self.element;
|
||||
|
||||
// In case a user constructs an outline entry with an arbitrary element.
|
||||
let Some(location) = elem.location() else {
|
||||
@ -512,7 +511,7 @@ impl Show for Packed<OutlineEntry> {
|
||||
seq.push(TextElem::packed("\u{202B}"));
|
||||
}
|
||||
|
||||
seq.push(self.body().clone().linked(Destination::Location(location)));
|
||||
seq.push(self.body.clone().linked(Destination::Location(location)));
|
||||
|
||||
if rtl {
|
||||
// "Pop Directional Formatting"
|
||||
@ -520,7 +519,7 @@ impl Show for Packed<OutlineEntry> {
|
||||
}
|
||||
|
||||
// Add filler symbols between the section name and page number.
|
||||
if let Some(filler) = self.fill() {
|
||||
if let Some(filler) = &self.fill {
|
||||
seq.push(SpaceElem::shared().clone());
|
||||
seq.push(
|
||||
BoxElem::new()
|
||||
@ -535,7 +534,7 @@ impl Show for Packed<OutlineEntry> {
|
||||
}
|
||||
|
||||
// Add the page number.
|
||||
let page = self.page().clone().linked(Destination::Location(location));
|
||||
let page = self.page.clone().linked(Destination::Location(location));
|
||||
seq.push(page);
|
||||
|
||||
Ok(Content::sequence(seq))
|
||||
|
@ -156,7 +156,7 @@ cast! {
|
||||
impl Show for Packed<QuoteElem> {
|
||||
#[typst_macros::time(name = "quote", span = self.span())]
|
||||
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
let mut realized = self.body().clone();
|
||||
let mut realized = self.body.clone();
|
||||
let block = self.block(styles);
|
||||
|
||||
if self.quotes(styles) == Smart::Custom(true) || !block {
|
||||
|
@ -182,9 +182,8 @@ impl Synthesize for Packed<RefElem> {
|
||||
elem.push_citation(Some(citation));
|
||||
elem.push_element(None);
|
||||
|
||||
let target = *elem.target();
|
||||
if !BibliographyElem::has(engine, target) {
|
||||
if let Ok(found) = engine.introspector.query_label(target).cloned() {
|
||||
if !BibliographyElem::has(engine, elem.target) {
|
||||
if let Ok(found) = engine.introspector.query_label(elem.target).cloned() {
|
||||
elem.push_element(Some(found));
|
||||
return Ok(());
|
||||
}
|
||||
@ -197,8 +196,7 @@ impl Synthesize for Packed<RefElem> {
|
||||
impl Show for Packed<RefElem> {
|
||||
#[typst_macros::time(name = "ref", span = self.span())]
|
||||
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
let target = *self.target();
|
||||
let elem = engine.introspector.query_label(target);
|
||||
let elem = engine.introspector.query_label(self.target);
|
||||
let span = self.span();
|
||||
|
||||
let form = self.form(styles);
|
||||
@ -229,7 +227,7 @@ impl Show for Packed<RefElem> {
|
||||
}
|
||||
// RefForm::Normal
|
||||
|
||||
if BibliographyElem::has(engine, target) {
|
||||
if BibliographyElem::has(engine, self.target) {
|
||||
if elem.is_ok() {
|
||||
bail!(span, "label occurs in the document and its bibliography");
|
||||
}
|
||||
@ -240,7 +238,7 @@ impl Show for Packed<RefElem> {
|
||||
let elem = elem.at(span)?;
|
||||
|
||||
if let Some(footnote) = elem.to_packed::<FootnoteElem>() {
|
||||
return Ok(footnote.into_ref(target).pack().spanned(span));
|
||||
return Ok(footnote.into_ref(self.target).pack().spanned(span));
|
||||
}
|
||||
|
||||
let elem = elem.clone();
|
||||
@ -319,7 +317,7 @@ fn to_citation(
|
||||
engine: &mut Engine,
|
||||
styles: StyleChain,
|
||||
) -> SourceResult<Packed<CiteElem>> {
|
||||
let mut elem = Packed::new(CiteElem::new(*reference.target()).with_supplement(
|
||||
let mut elem = Packed::new(CiteElem::new(reference.target).with_supplement(
|
||||
match reference.supplement(styles).clone() {
|
||||
Smart::Custom(Some(Supplement::Content(content))) => Some(content),
|
||||
_ => None,
|
||||
|
@ -706,7 +706,7 @@ cast! {
|
||||
|
||||
impl Show for Packed<TableCell> {
|
||||
fn show(&self, _engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
show_grid_cell(self.body().clone(), self.inset(styles), self.align(styles))
|
||||
show_grid_cell(self.body.clone(), self.inset(styles), self.align(styles))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,12 +151,12 @@ impl Show for Packed<TermsElem> {
|
||||
.then(|| HElem::new((-hanging_indent).into()).pack().spanned(span));
|
||||
|
||||
let mut children = vec![];
|
||||
for child in self.children().iter() {
|
||||
for child in self.children.iter() {
|
||||
let mut seq = vec![];
|
||||
seq.extend(unpad.clone());
|
||||
seq.push(child.term().clone().strong());
|
||||
seq.push(child.term.clone().strong());
|
||||
seq.push((*separator).clone());
|
||||
seq.push(child.description().clone());
|
||||
seq.push(child.description.clone());
|
||||
children.push(StackChild::Block(Content::sequence(seq)));
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)))
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,11 @@ impl Elem {
|
||||
self.real_fields().filter(|field| !field.ghost)
|
||||
}
|
||||
|
||||
/// Fields that get accessor, with, and push methods.
|
||||
fn accessor_fields(&self) -> impl Iterator<Item = &Field> + Clone {
|
||||
self.struct_fields().filter(|field| !field.required)
|
||||
}
|
||||
|
||||
/// Fields that are relevant for equality.
|
||||
///
|
||||
/// Synthesized fields are excluded to ensure equality before and after
|
||||
@ -442,9 +447,9 @@ fn create_inherent_impl(element: &Elem) -> TokenStream {
|
||||
let Elem { ident, .. } = element;
|
||||
|
||||
let new_func = create_new_func(element);
|
||||
let with_field_methods = element.struct_fields().map(create_with_field_method);
|
||||
let push_field_methods = element.struct_fields().map(create_push_field_method);
|
||||
let field_methods = element.struct_fields().map(create_field_method);
|
||||
let with_field_methods = element.accessor_fields().map(create_with_field_method);
|
||||
let push_field_methods = element.accessor_fields().map(create_push_field_method);
|
||||
let field_methods = element.accessor_fields().map(create_field_method);
|
||||
let field_in_methods = element.style_fields().map(create_field_in_method);
|
||||
let set_field_methods = element.style_fields().map(create_set_field_method);
|
||||
|
||||
|
@ -59,7 +59,7 @@ fn embed_file(
|
||||
let embedded_file_stream_ref = chunk.alloc.bump();
|
||||
let file_spec_dict_ref = chunk.alloc.bump();
|
||||
|
||||
let data = embed.data().as_slice();
|
||||
let data = embed.data.as_slice();
|
||||
let compressed = deflate(data);
|
||||
|
||||
let mut embedded_file = chunk.embedded_file(embedded_file_stream_ref, &compressed);
|
||||
|
@ -184,8 +184,7 @@ fn write_outline_item(
|
||||
outline.count(-(node.children.len() as i32));
|
||||
}
|
||||
|
||||
let body = node.element.body();
|
||||
outline.title(TextStr::trimmed(body.plain_text().trim()));
|
||||
outline.title(TextStr::trimmed(node.element.body.plain_text().trim()));
|
||||
|
||||
let loc = node.element.location().unwrap();
|
||||
let pos = ctx.document.introspector.position(loc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user