summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/src/main.rs6
-rw-r--r--library/src/compute/calc.rs2
-rw-r--r--library/src/layout/flow.rs4
-rw-r--r--library/src/layout/fragment.rs5
-rw-r--r--library/src/layout/grid.rs2
-rw-r--r--library/src/layout/list.rs2
-rw-r--r--library/src/layout/mod.rs10
-rw-r--r--library/src/layout/par.rs9
-rw-r--r--library/src/layout/stack.rs2
-rw-r--r--library/src/math/ctx.rs4
-rw-r--r--library/src/math/mod.rs2
-rw-r--r--library/src/meta/bibliography.rs6
-rw-r--r--library/src/meta/outline.rs2
-rw-r--r--library/src/meta/reference.rs2
-rw-r--r--library/src/symbols/emoji.rs2
-rw-r--r--library/src/symbols/sym.rs2
-rw-r--r--library/src/text/shaping.rs2
-rw-r--r--library/src/text/shift.rs2
-rw-r--r--library/src/visualize/polygon.rs2
19 files changed, 37 insertions, 31 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index 95bafa65..e8b08bdb 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -279,7 +279,7 @@ fn compile_once(world: &mut SystemWorld, command: &CompileSettings) -> StrResult
// Print diagnostics.
Err(errors) => {
status(command, Status::Error).unwrap();
- print_diagnostics(&world, *errors)
+ print_diagnostics(world, *errors)
.map_err(|_| "failed to print diagnostics")?;
Ok(true)
}
@@ -576,10 +576,10 @@ impl PathHash {
/// Read a file.
fn read(path: &Path) -> FileResult<Vec<u8>> {
let f = |e| FileError::from_io(e, path);
- if fs::metadata(&path).map_err(f)?.is_dir() {
+ if fs::metadata(path).map_err(f)?.is_dir() {
Err(FileError::IsDirectory)
} else {
- fs::read(&path).map_err(f)
+ fs::read(path).map_err(f)
}
}
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs
index d98d09b2..bb5d9002 100644
--- a/library/src/compute/calc.rs
+++ b/library/src/compute/calc.rs
@@ -457,7 +457,7 @@ pub fn round(
Num::Int(n) if digits == 0 => Value::Int(n),
_ => {
let n = value.float();
- let factor = 10.0_f64.powi(digits as i32) as f64;
+ let factor = 10.0_f64.powi(digits as i32);
Value::Float((n * factor).round() / factor)
}
}
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs
index da2ddba6..cd7b1f60 100644
--- a/library/src/layout/flow.rs
+++ b/library/src/layout/flow.rs
@@ -30,7 +30,7 @@ impl Layout for FlowElem {
let mut styles = styles;
if let Some((elem, map)) = child.to_styled() {
child = elem;
- styles = outer.chain(&map);
+ styles = outer.chain(map);
}
if let Some(elem) = child.to::<VElem>() {
@@ -54,7 +54,7 @@ impl Layout for FlowElem {
true,
));
} else if child.can::<dyn Layout>() {
- layouter.layout_multiple(vt, &child, styles)?;
+ layouter.layout_multiple(vt, child, styles)?;
} else if child.is::<ColbreakElem>() {
if !layouter.regions.backlog.is_empty() || layouter.regions.last.is_some()
{
diff --git a/library/src/layout/fragment.rs b/library/src/layout/fragment.rs
index d1f6b524..3550df2a 100644
--- a/library/src/layout/fragment.rs
+++ b/library/src/layout/fragment.rs
@@ -15,6 +15,11 @@ impl Fragment {
Self(frames)
}
+ /// Return `true` if the length is 0.
+ pub fn is_empty(&self) -> bool {
+ self.0.is_empty()
+ }
+
/// The number of frames in the fragment.
pub fn len(&self) -> usize {
self.0.len()
diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs
index e0c8b684..01bf7e30 100644
--- a/library/src/layout/grid.rs
+++ b/library/src/layout/grid.rs
@@ -267,7 +267,7 @@ impl<'a, 'v> GridLayouter<'a, 'v> {
// We use these regions for auto row measurement. Since at that moment,
// columns are already sized, we can enable horizontal expansion.
- let mut regions = regions.clone();
+ let mut regions = regions;
regions.expand = Axes::new(true, false);
Self {
diff --git a/library/src/layout/list.rs b/library/src/layout/list.rs
index 9f8d5a92..6cb1bc7e 100644
--- a/library/src/layout/list.rs
+++ b/library/src/layout/list.rs
@@ -197,7 +197,7 @@ cast_from_value! {
ListMarker,
v: Content => Self::Content(vec![v]),
array: Array => {
- if array.len() == 0 {
+ if array.is_empty() {
Err("array must contain at least one marker")?;
}
Self::Content(array.into_iter().map(Value::display).collect())
diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs
index 1e437723..e93b2e02 100644
--- a/library/src/layout/mod.rs
+++ b/library/src/layout/mod.rs
@@ -172,7 +172,7 @@ fn realize_root<'a>(
return Ok((content.clone(), styles));
}
- let mut builder = Builder::new(vt, &scratch, true);
+ let mut builder = Builder::new(vt, scratch, true);
builder.accept(content, styles)?;
builder.interrupt_page(Some(styles))?;
let (pages, shared) = builder.doc.unwrap().pages.finish();
@@ -197,7 +197,7 @@ fn realize_block<'a>(
return Ok((content.clone(), styles));
}
- let mut builder = Builder::new(vt, &scratch, false);
+ let mut builder = Builder::new(vt, scratch, false);
builder.accept(content, styles)?;
builder.interrupt_par()?;
let (children, shared) = builder.flow.0.finish();
@@ -314,7 +314,7 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> {
) -> SourceResult<()> {
let stored = self.scratch.styles.alloc(styles);
let styles = stored.chain(map);
- self.interrupt_style(&map, None)?;
+ self.interrupt_style(map, None)?;
self.accept(elem, styles)?;
self.interrupt_style(map, Some(styles))?;
Ok(())
@@ -468,9 +468,9 @@ impl<'a> FlowBuilder<'a> {
let above = BlockElem::above_in(styles);
let below = BlockElem::below_in(styles);
- self.0.push(above.clone().pack(), styles);
+ self.0.push(above.pack(), styles);
self.0.push(content.clone(), styles);
- self.0.push(below.clone().pack(), styles);
+ self.0.push(below.pack(), styles);
return true;
}
diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs
index dc445c86..7e43b43f 100644
--- a/library/src/layout/par.rs
+++ b/library/src/layout/par.rs
@@ -365,12 +365,13 @@ impl<'a> Item<'a> {
}
/// Maps byte offsets back to spans.
+#[derive(Default)]
pub struct SpanMapper(Vec<(usize, Span)>);
impl SpanMapper {
/// Create a new span mapper.
pub fn new() -> Self {
- Self(vec![])
+ Self::default()
}
/// Push a span for a segment with the given length.
@@ -745,8 +746,8 @@ fn is_compatible(a: Script, b: Script) -> bool {
/// Get a style property, but only if it is the same for all children of the
/// paragraph.
-fn shared_get<'a, T: PartialEq>(
- styles: StyleChain<'a>,
+fn shared_get<T: PartialEq>(
+ styles: StyleChain<'_>,
children: &[Content],
getter: fn(StyleChain) -> T,
) -> Option<T> {
@@ -754,7 +755,7 @@ fn shared_get<'a, T: PartialEq>(
children
.iter()
.filter_map(|child| child.to_styled())
- .all(|(_, local)| getter(styles.chain(&local)) == value)
+ .all(|(_, local)| getter(styles.chain(local)) == value)
.then(|| value)
}
diff --git a/library/src/layout/stack.rs b/library/src/layout/stack.rs
index c85eda2d..8146114a 100644
--- a/library/src/layout/stack.rs
+++ b/library/src/layout/stack.rs
@@ -198,7 +198,7 @@ impl<'a> StackLayouter<'a> {
let aligns = if let Some(align) = block.to::<AlignElem>() {
align.alignment(styles)
} else if let Some((_, local)) = block.to_styled() {
- AlignElem::alignment_in(styles.chain(&local))
+ AlignElem::alignment_in(styles.chain(local))
} else {
AlignElem::alignment_in(styles)
}
diff --git a/library/src/math/ctx.rs b/library/src/math/ctx.rs
index 904c4333..bad0fe5a 100644
--- a/library/src/math/ctx.rs
+++ b/library/src/math/ctx.rs
@@ -61,7 +61,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
Self {
vt,
regions: Regions::one(regions.base(), Axes::splat(false)),
- font: &font,
+ font,
ttf: font.ttf(),
table,
constants,
@@ -120,7 +120,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
pub fn layout_content(&mut self, content: &Content) -> SourceResult<Frame> {
Ok(content
- .layout(&mut self.vt, self.outer.chain(&self.local), self.regions)?
+ .layout(self.vt, self.outer.chain(&self.local), self.regions)?
.into_frame())
}
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 467f91ff..a25c5039 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -297,7 +297,7 @@ impl LayoutMath for Content {
}
if let Some((elem, styles)) = self.to_styled() {
- if TextElem::font_in(ctx.styles().chain(&styles))
+ if TextElem::font_in(ctx.styles().chain(styles))
!= TextElem::font_in(ctx.styles())
{
let frame = ctx.layout_content(self)?;
diff --git a/library/src/meta/bibliography.rs b/library/src/meta/bibliography.rs
index ac2dea75..19126291 100644
--- a/library/src/meta/bibliography.rs
+++ b/library/src/meta/bibliography.rs
@@ -52,7 +52,7 @@ pub struct BibliographyElem {
args.expect::<Spanned<BibPaths>>("path to bibliography file")?;
for path in &mut paths.0 {
// resolve paths
- *path = vm.locate(&path).at(span)?.to_string_lossy().into();
+ *path = vm.locate(path).at(span)?.to_string_lossy().into();
}
// check that parsing works
let _ = load(vm.world(), &paths).at(span)?;
@@ -145,7 +145,7 @@ impl Show for BibliographyElem {
let mut seq = vec![];
if let Some(title) = self.title(styles) {
- let title = title.clone().unwrap_or_else(|| {
+ let title = title.unwrap_or_else(|| {
TextElem::packed(self.local_name(TextElem::lang_in(styles)))
.spanned(self.span())
});
@@ -526,7 +526,7 @@ fn create(
// Make link from citation to here work.
let backlink = {
let mut content = Content::empty();
- content.set_location(ref_location(&reference.entry));
+ content.set_location(ref_location(reference.entry));
MetaElem::set_data(vec![Meta::Elem(content)])
};
diff --git a/library/src/meta/outline.rs b/library/src/meta/outline.rs
index dbf879c3..33b6b70a 100644
--- a/library/src/meta/outline.rs
+++ b/library/src/meta/outline.rs
@@ -73,7 +73,7 @@ impl Show for OutlineElem {
fn show(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
let mut seq = vec![ParbreakElem::new().pack()];
if let Some(title) = self.title(styles) {
- let title = title.clone().unwrap_or_else(|| {
+ let title = title.unwrap_or_else(|| {
TextElem::packed(self.local_name(TextElem::lang_in(styles)))
.spanned(self.span())
});
diff --git a/library/src/meta/reference.rs b/library/src/meta/reference.rs
index 0b317db0..24687845 100644
--- a/library/src/meta/reference.rs
+++ b/library/src/meta/reference.rs
@@ -119,7 +119,7 @@ impl Show for RefElem {
.map(TextElem::packed)
.unwrap_or_default(),
Smart::Custom(None) => Content::empty(),
- Smart::Custom(Some(Supplement::Content(content))) => content.clone(),
+ Smart::Custom(Some(Supplement::Content(content))) => content,
Smart::Custom(Some(Supplement::Func(func))) => {
func.call_vt(vt, [elem.clone().into()])?.display()
}
diff --git a/library/src/symbols/emoji.rs b/library/src/symbols/emoji.rs
index 5db3a799..44bc3e14 100644
--- a/library/src/symbols/emoji.rs
+++ b/library/src/symbols/emoji.rs
@@ -10,7 +10,7 @@ pub fn emoji() -> Module {
}
/// A list of named emoji.
-const EMOJI: &[(&'static str, Symbol)] = symbols! {
+const EMOJI: &[(&str, Symbol)] = symbols! {
abacus: '🧮',
abc: '🔤',
abcd: '🔡',
diff --git a/library/src/symbols/sym.rs b/library/src/symbols/sym.rs
index f1cf6649..22c9a1ec 100644
--- a/library/src/symbols/sym.rs
+++ b/library/src/symbols/sym.rs
@@ -10,7 +10,7 @@ pub fn sym() -> Module {
}
/// The list of general symbols.
-pub(crate) const SYM: &[(&'static str, Symbol)] = symbols! {
+pub(crate) const SYM: &[(&str, Symbol)] = symbols! {
// Control.
wj: '\u{2060}',
zwj: '\u{200D}',
diff --git a/library/src/text/shaping.rs b/library/src/text/shaping.rs
index 4a62d538..b895b6f9 100644
--- a/library/src/text/shaping.rs
+++ b/library/src/text/shaping.rs
@@ -384,7 +384,7 @@ pub fn shape<'a>(
}
/// Shape text with font fallback using the `families` iterator.
-fn shape_segment<'a>(
+fn shape_segment(
ctx: &mut ShapingContext,
base: usize,
text: &str,
diff --git a/library/src/text/shift.rs b/library/src/text/shift.rs
index 1bea3673..26978b87 100644
--- a/library/src/text/shift.rs
+++ b/library/src/text/shift.rs
@@ -135,7 +135,7 @@ fn search_text(content: &Content, sub: bool) -> Option<EcoString> {
} else if let Some(children) = content.to_sequence() {
let mut full = EcoString::new();
for item in children {
- match search_text(&item, sub) {
+ match search_text(item, sub) {
Some(text) => full.push_str(&text),
None => return None,
}
diff --git a/library/src/visualize/polygon.rs b/library/src/visualize/polygon.rs
index 07725b72..642349fa 100644
--- a/library/src/visualize/polygon.rs
+++ b/library/src/visualize/polygon.rs
@@ -62,7 +62,7 @@ impl Layout for PolygonElem {
let mut frame = Frame::new(target);
// Only create a path if there are more than zero points.
- if points.len() > 0 {
+ if !points.is_empty() {
let fill = self.fill(styles);
let stroke = self.stroke(styles).map(PartialStroke::unwrap_or_default);