clippy::wrong_self_convention (#857)
This commit is contained in:
parent
56673bcdf5
commit
dd5e9723e0
@ -237,7 +237,7 @@ impl<'a> StackLayouter<'a> {
|
||||
// the region expands.
|
||||
let mut size = self
|
||||
.expand
|
||||
.select(self.initial, self.used.to_axes(self.axis))
|
||||
.select(self.initial, self.used.into_axes(self.axis))
|
||||
.min(self.initial);
|
||||
|
||||
// Expand fully if there are fr spacings.
|
||||
@ -318,7 +318,7 @@ impl<T> Gen<T> {
|
||||
}
|
||||
|
||||
/// Convert to the specific representation, given the current main axis.
|
||||
fn to_axes(self, main: Axis) -> Axes<T> {
|
||||
fn into_axes(self, main: Axis) -> Axes<T> {
|
||||
match main {
|
||||
Axis::X => Axes::new(self.main, self.cross),
|
||||
Axis::Y => Axes::new(self.cross, self.main),
|
||||
@ -334,6 +334,6 @@ impl Gen<Abs> {
|
||||
|
||||
/// Convert to a point.
|
||||
fn to_point(self, main: Axis) -> Point {
|
||||
self.to_axes(main).to_point()
|
||||
self.into_axes(main).to_point()
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ impl LayoutMath for AccentElem {
|
||||
let mut frame = Frame::new(size);
|
||||
frame.set_baseline(baseline);
|
||||
frame.push_frame(accent_pos, accent);
|
||||
frame.push_frame(base_pos, base.to_frame());
|
||||
frame.push_frame(base_pos, base.into_frame());
|
||||
ctx.push(FrameFragment::new(ctx, frame).with_base_ascent(base_ascent));
|
||||
|
||||
Ok(())
|
||||
|
@ -191,18 +191,18 @@ fn scripts(
|
||||
|
||||
let mut frame = Frame::new(Size::new(width, ascent + descent));
|
||||
frame.set_baseline(ascent);
|
||||
frame.push_frame(base_pos, base.to_frame());
|
||||
frame.push_frame(base_pos, base.into_frame());
|
||||
|
||||
if let Some(sup) = sup {
|
||||
let sup_pos =
|
||||
Point::new(sup_delta + base_width, ascent - shift_up - sup.ascent());
|
||||
frame.push_frame(sup_pos, sup.to_frame());
|
||||
frame.push_frame(sup_pos, sup.into_frame());
|
||||
}
|
||||
|
||||
if let Some(sub) = sub {
|
||||
let sub_pos =
|
||||
Point::new(sub_delta + base_width, ascent + shift_down - sub.ascent());
|
||||
frame.push_frame(sub_pos, sub.to_frame());
|
||||
frame.push_frame(sub_pos, sub.into_frame());
|
||||
}
|
||||
|
||||
ctx.push(FrameFragment::new(ctx, frame).with_class(class));
|
||||
@ -245,17 +245,17 @@ fn limits(
|
||||
|
||||
let mut frame = Frame::new(Size::new(width, height));
|
||||
frame.set_baseline(base_pos.y + base.ascent());
|
||||
frame.push_frame(base_pos, base.to_frame());
|
||||
frame.push_frame(base_pos, base.into_frame());
|
||||
|
||||
if let Some(top) = top {
|
||||
let top_pos = Point::with_x((width - top.width()) / 2.0 + delta);
|
||||
frame.push_frame(top_pos, top.to_frame());
|
||||
frame.push_frame(top_pos, top.into_frame());
|
||||
}
|
||||
|
||||
if let Some(bottom) = bottom {
|
||||
let bottom_pos =
|
||||
Point::new((width - bottom.width()) / 2.0 - delta, height - bottom.height());
|
||||
frame.push_frame(bottom_pos, bottom.to_frame());
|
||||
frame.push_frame(bottom_pos, bottom.into_frame());
|
||||
}
|
||||
|
||||
ctx.push(FrameFragment::new(ctx, frame).with_class(class));
|
||||
|
@ -98,7 +98,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
|
||||
elem: &dyn LayoutMath,
|
||||
) -> SourceResult<MathFragment> {
|
||||
let row = self.layout_fragments(elem)?;
|
||||
Ok(MathRow::new(row).to_fragment(self))
|
||||
Ok(MathRow::new(row).into_fragment(self))
|
||||
}
|
||||
|
||||
pub fn layout_fragments(
|
||||
@ -116,7 +116,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
|
||||
}
|
||||
|
||||
pub fn layout_frame(&mut self, elem: &dyn LayoutMath) -> SourceResult<Frame> {
|
||||
Ok(self.layout_fragment(elem)?.to_frame())
|
||||
Ok(self.layout_fragment(elem)?.into_frame())
|
||||
}
|
||||
|
||||
pub fn layout_content(&mut self, content: &Content) -> SourceResult<Frame> {
|
||||
@ -151,7 +151,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
|
||||
let c = self.style.styled_char(c);
|
||||
fragments.push(GlyphFragment::new(self, c, span).into());
|
||||
}
|
||||
let frame = MathRow::new(fragments).to_frame(self);
|
||||
let frame = MathRow::new(fragments).into_frame(self);
|
||||
FrameFragment::new(self, frame).into()
|
||||
} else {
|
||||
// Anything else is handled by Typst's standard text layout.
|
||||
|
@ -105,9 +105,9 @@ impl MathFragment {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_frame(self) -> Frame {
|
||||
pub fn into_frame(self) -> Frame {
|
||||
match self {
|
||||
Self::Glyph(glyph) => glyph.to_frame(),
|
||||
Self::Glyph(glyph) => glyph.into_frame(),
|
||||
Self::Variant(variant) => variant.frame,
|
||||
Self::Frame(fragment) => fragment.frame,
|
||||
_ => Frame::new(self.size()),
|
||||
@ -201,7 +201,7 @@ impl GlyphFragment {
|
||||
self.ascent + self.descent
|
||||
}
|
||||
|
||||
pub fn to_variant(self) -> VariantFragment {
|
||||
pub fn into_variant(self) -> VariantFragment {
|
||||
VariantFragment {
|
||||
c: self.c,
|
||||
id: Some(self.id),
|
||||
@ -210,11 +210,11 @@ impl GlyphFragment {
|
||||
italics_correction: self.italics_correction,
|
||||
class: self.class,
|
||||
span: self.span,
|
||||
frame: self.to_frame(),
|
||||
frame: self.into_frame(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_frame(self) -> Frame {
|
||||
pub fn into_frame(self) -> Frame {
|
||||
let item = TextItem {
|
||||
font: self.font.clone(),
|
||||
size: self.font_size,
|
||||
|
@ -268,7 +268,7 @@ fn layout_mat_body(ctx: &mut MathContext, rows: &[Vec<Content>]) -> SourceResult
|
||||
let points = alignments(&col);
|
||||
let mut y = Abs::zero();
|
||||
for ((cell, &ascent), &descent) in col.into_iter().zip(&ascents).zip(&descents) {
|
||||
let cell = cell.to_aligned_frame(ctx, &points, Align::Center);
|
||||
let cell = cell.into_aligned_frame(ctx, &points, Align::Center);
|
||||
let pos =
|
||||
Point::new(x + (rcol - cell.width()) / 2.0, y + ascent - cell.ascent());
|
||||
frame.push_frame(pos, cell);
|
||||
|
@ -38,7 +38,7 @@ impl LayoutMath for OpElem {
|
||||
let fragment =
|
||||
ctx.layout_text(&TextElem::new(self.text()).spanned(self.span()))?;
|
||||
ctx.push(
|
||||
FrameFragment::new(ctx, fragment.to_frame())
|
||||
FrameFragment::new(ctx, fragment.into_frame())
|
||||
.with_class(MathClass::Large)
|
||||
.with_limits(self.limits(ctx.styles())),
|
||||
);
|
||||
|
@ -99,21 +99,21 @@ impl MathRow {
|
||||
self.iter().map(MathFragment::descent).max().unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn to_frame(self, ctx: &MathContext) -> Frame {
|
||||
pub fn into_frame(self, ctx: &MathContext) -> Frame {
|
||||
let styles = ctx.styles();
|
||||
let align = AlignElem::alignment_in(styles).x.resolve(styles);
|
||||
self.to_aligned_frame(ctx, &[], align)
|
||||
self.into_aligned_frame(ctx, &[], align)
|
||||
}
|
||||
|
||||
pub fn to_fragment(self, ctx: &MathContext) -> MathFragment {
|
||||
pub fn into_fragment(self, ctx: &MathContext) -> MathFragment {
|
||||
if self.0.len() == 1 {
|
||||
self.0.into_iter().next().unwrap()
|
||||
} else {
|
||||
FrameFragment::new(ctx, self.to_frame(ctx)).into()
|
||||
FrameFragment::new(ctx, self.into_frame(ctx)).into()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_aligned_frame(
|
||||
pub fn into_aligned_frame(
|
||||
mut self,
|
||||
ctx: &MathContext,
|
||||
points: &[Abs],
|
||||
@ -141,7 +141,7 @@ impl MathRow {
|
||||
let mut frame = Frame::new(Size::zero());
|
||||
|
||||
for (i, row) in rows.into_iter().enumerate() {
|
||||
let sub = row.to_line_frame(&points, align);
|
||||
let sub = row.into_line_frame(&points, align);
|
||||
let size = frame.size_mut();
|
||||
if i > 0 {
|
||||
size.y += leading;
|
||||
@ -157,11 +157,11 @@ impl MathRow {
|
||||
}
|
||||
frame
|
||||
} else {
|
||||
self.to_line_frame(points, align)
|
||||
self.into_line_frame(points, align)
|
||||
}
|
||||
}
|
||||
|
||||
fn to_line_frame(self, points: &[Abs], align: Align) -> Frame {
|
||||
fn into_line_frame(self, points: &[Abs], align: Align) -> Frame {
|
||||
let ascent = self.ascent();
|
||||
let descent = self.descent();
|
||||
let size = Size::new(Abs::zero(), ascent + descent);
|
||||
@ -194,7 +194,7 @@ impl MathRow {
|
||||
let y = ascent - fragment.ascent();
|
||||
let pos = Point::new(x, y);
|
||||
x += fragment.width();
|
||||
frame.push_frame(pos, fragment.to_frame());
|
||||
frame.push_frame(pos, fragment.into_frame());
|
||||
}
|
||||
|
||||
frame.size_mut().x = x;
|
||||
|
@ -57,7 +57,7 @@ fn stretch_glyph(
|
||||
// If the base glyph is good enough, use it.
|
||||
let advance = if horizontal { base.width } else { base.height() };
|
||||
if short_target <= advance {
|
||||
return base.to_variant();
|
||||
return base.into_variant();
|
||||
}
|
||||
|
||||
// Search for a pre-made variant with a good advance.
|
||||
@ -73,7 +73,7 @@ fn stretch_glyph(
|
||||
|
||||
// This is either good or the best we've got.
|
||||
if short_target <= best_advance || construction.assembly.is_none() {
|
||||
return GlyphFragment::with_id(ctx, base.c, best_id, base.span).to_variant();
|
||||
return GlyphFragment::with_id(ctx, base.c, best_id, base.span).into_variant();
|
||||
}
|
||||
|
||||
// Assemble from parts.
|
||||
@ -169,7 +169,7 @@ fn assemble(
|
||||
} else {
|
||||
Point::with_y(full - offset - fragment.height())
|
||||
};
|
||||
frame.push_frame(pos, fragment.to_frame());
|
||||
frame.push_frame(pos, fragment.into_frame());
|
||||
offset += advance;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ pub(super) fn stack(
|
||||
let points = alignments(&rows);
|
||||
let rows: Vec<_> = rows
|
||||
.into_iter()
|
||||
.map(|row| row.to_aligned_frame(ctx, &points, align))
|
||||
.map(|row| row.into_aligned_frame(ctx, &points, align))
|
||||
.collect();
|
||||
|
||||
for row in &rows {
|
||||
|
Loading…
x
Reference in New Issue
Block a user