Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod write;
/// assert_eq!(padded_length, 124);
/// ```
pub const fn long_align(len: usize) -> usize {
(len + 3) / 4 * 4
len.div_ceil(4) * 4
}

/// Calculate the length required to 16-bit (word) align data of length `len`
Expand All @@ -32,7 +32,7 @@ pub const fn long_align(len: usize) -> usize {
/// assert_eq!(padded_length, 124);
/// ```
pub const fn word_align(len: usize) -> usize {
(len + 1) / 2 * 2
len.div_ceil(2) * 2
}

/// Unsigned 8-bit binary type.
Expand Down
4 changes: 2 additions & 2 deletions src/binary/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ pub struct ReadArray<'a, T: ReadFixedSizeDep> {
args: T::Args<'a>,
}

impl<'a, T: ReadFixedSizeDep> Clone for ReadArray<'a, T> {
impl<T: ReadFixedSizeDep> Clone for ReadArray<'_, T> {
fn clone(&self) -> Self {
*self
}
}

impl<'a, T: ReadFixedSizeDep> Copy for ReadArray<'a, T> {}
impl<T: ReadFixedSizeDep> Copy for ReadArray<'_, T> {}

pub struct ReadArrayIter<'a, T: ReadUnchecked> {
scope: ReadScope<'a>,
Expand Down
3 changes: 1 addition & 2 deletions src/binary/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

//! Write binary data

use std::iter;
use std::marker::PhantomData;

use crate::binary::read::{ReadArray, ReadArrayCow, ReadScope, ReadUnchecked};
Expand Down Expand Up @@ -313,7 +312,7 @@ impl WriteContext for WriteBuffer {
}

fn write_zeros(&mut self, count: usize) -> Result<(), WriteError> {
let zeros = iter::repeat(0).take(count);
let zeros = std::iter::repeat_n(0, count);
self.data.extend(zeros);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/cff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ impl TryFrom<&Operand> for f32 {
.contains(int)
.then_some(*int as f32)
.ok_or(ParseError::LimitExceeded),
Operand::Real(r) => f64::try_from(r).map_err(ParseError::from).and_then(|val| {
Operand::Real(r) => f64::try_from(r).and_then(|val| {
(f32::MIN as f64..=f32::MAX as f64)
.contains(&val)
.then_some(val as f32)
Expand Down
2 changes: 1 addition & 1 deletion src/cff/charstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ impl<'a, 'data> CharStringVisitorContext<'a, 'data> {
return Err(CFFError::MissingVariationStore.into());
};

if stack.len() > 0 {
if !stack.is_empty() {
visitor.visit(op.try_into().unwrap(), stack)?;

// Lookup the ItemVariationStore data to get the variation regions
Expand Down
2 changes: 1 addition & 1 deletion src/cff/subset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ fn copy_used_subrs(
if dst_subr_index
.data
.get(subr_index)
.map_or(false, |subr| !subr.is_empty())
.is_some_and(|subr| !subr.is_empty())
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gdef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn glyph_is_mark_in_set(opt_gdef_table: Option<&GDEFTable>, glyph: u16, inde
&& opt_gdef_table
.and_then(|gdef| gdef.opt_mark_glyph_sets.as_ref())
.and_then(|mark_glyph_sets| mark_glyph_sets.get(index))
.map_or(false, |mark_set| {
.is_some_and(|mark_set| {
mark_set.glyph_coverage_value(glyph).is_some()
})
}
2 changes: 1 addition & 1 deletion src/glyph_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ fn is_upright_glyph(info: &Info) -> bool {
.glyph
.unicodes
.first()
.map_or(false, |&ch| is_upright_char(ch))
.is_some_and(|&ch| is_upright_char(ch))
}

#[cfg(test)]
Expand Down
7 changes: 2 additions & 5 deletions src/gsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ fn apply_subst_context<T: GlyphData>(
None => return Ok(None), // FIXME actually an error/impossible?
};
for (subst_index, subst_lookup_index) in subst.lookup_array {
match apply_subst(
if let Some(changes0) = apply_subst(
recursion_limit,
gsub_cache,
lookup_list,
Expand All @@ -720,10 +720,7 @@ fn apply_subst_context<T: GlyphData>(
feature_tag,
glyphs,
i,
)? {
Some(changes0) => changes += changes0,
None => {}
}
)? { changes += changes0 }
}
match checked_add(len, changes) {
Some(new_len) => Ok(Some((new_len, changes))),
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/myanmar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ fn tag_syllable(
// with POS_BEFORE_SUBJOINED
else if glyph.is(a)
&& prev_glyph_skip(before_i, a)
.map_or(false, |prev| prev.pos() == Some(Pos::BelowbaseConsonant))
.is_some_and(|prev| prev.pos() == Some(Pos::BelowbaseConsonant))
{
glyph.set_pos(Some(Pos::BeforeSubjoined))
}
Expand Down
3 changes: 1 addition & 2 deletions src/tables/cmap/subset.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::BTreeMap;
use std::iter;
use std::marker::PhantomData;

use crate::big5::big5_to_unicode;
Expand Down Expand Up @@ -128,7 +127,7 @@ impl<'a> CmapSubtableFormat4Segment<'a> {
let prev = self.glyph_ids.last().copied().unwrap();
self.consecutive_glyph_ids &= (prev + 1) == gid;
} else {
self.glyph_ids.extend(iter::repeat(0).take(gap as usize));
self.glyph_ids.extend(std::iter::repeat_n(0, gap as usize));
// if there's a gap then the glyph ids can't be consecutive
self.consecutive_glyph_ids = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/tables/glyf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod subset;
mod variation;

use std::rc::Rc;
use std::{iter, mem};
use std::mem;

use bitflags::bitflags;
use itertools::Itertools;
Expand Down Expand Up @@ -599,7 +599,7 @@ impl ReadBinaryDep for SimpleGlyph {
let flag = ctxt.read::<SimpleGlyphFlag>()?;
if flag.is_repeated() {
let count = usize::from(ctxt.read::<U8>()?) + 1; // + 1 to include the current entry
let repeat = iter::repeat((flag, Point::zero())).take(count);
let repeat = std::iter::repeat_n((flag, Point::zero()), count);
coordinates.extend(repeat)
} else {
coordinates.push((flag, Point::zero()));
Expand Down
8 changes: 4 additions & 4 deletions src/tables/glyf/outline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<'a, 'data> GlyfVisitorContext<'a, 'data> {
pub fn new(glyf: &'a mut LocaGlyf, variable: Option<VariableGlyfContext<'data>>) -> Self {
GlyfVisitorContext {
glyf,
variable: variable,
variable,
}
}

Expand Down Expand Up @@ -355,7 +355,7 @@ impl<'data> VariableGlyfContext<'data> {
///
/// The resulting instance can be passed to [GlyfVisitorContext::new] in order to visit the outlines
/// of a variable font.
pub fn new<'a>(store: &'data VariableGlyfContextStore<'data>) -> Result<Self, ParseError> {
pub fn new(store: &'data VariableGlyfContextStore<'data>) -> Result<Self, ParseError> {
let maxp = ReadScope::new(&store.maxp).read::<MaxpTable>()?;
let gvar = ReadScope::new(&store.gvar).read::<GvarTable<'data>>()?;
let hhea = ReadScope::new(&store.hhea).read::<HheaTable>()?;
Expand Down Expand Up @@ -391,7 +391,7 @@ impl<'data> VariableGlyfContext<'data> {
}
}

impl<'a, 'data> OutlineBuilder for GlyfVisitorContext<'a, 'data> {
impl OutlineBuilder for GlyfVisitorContext<'_, '_> {
type Error = ParseError;

fn visit<V: OutlineSink>(
Expand Down Expand Up @@ -473,7 +473,7 @@ mod contour {

impl<'points> Contour<'points> {
pub fn new(points_and_flags: &'points [(SimpleGlyphFlag, Point)]) -> Self {
assert!(points_and_flags.len() > 0);
assert!(!points_and_flags.is_empty());
Contour { points_and_flags }
}

Expand Down
11 changes: 4 additions & 7 deletions src/tables/glyf/variation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,11 @@ fn glyph_deltas(
// > number list, as follows.

// Only need to do this for simple glyphs
match glyph {
Glyph::Simple(simple_glyph) => {
// Deltas need to be inferred if not all points were assigned explicit deltas
if explicit_deltas.len() != usize::safe_from(num_points.get()) {
infer_unreferenced_points(&mut region_deltas, &explicit_deltas, simple_glyph)?;
}
if let Glyph::Simple(simple_glyph) = glyph {
// Deltas need to be inferred if not all points were assigned explicit deltas
if explicit_deltas.len() != usize::safe_from(num_points.get()) {
infer_unreferenced_points(&mut region_deltas, &explicit_deltas, simple_glyph)?;
}
_ => {}
}

// Scale and accumulate the deltas from this variation region onto the final deltas
Expand Down
2 changes: 1 addition & 1 deletion src/tables/kern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl<'a> From<&'a owned::KernTable> for KernTable<'a> {
}
}

impl<'a> KernSubtable<'a> {
impl KernSubtable<'_> {
/// True if table has horizontal data, false if vertical.
fn is_horizontal(&self) -> bool {
match self.coverage {
Expand Down
3 changes: 1 addition & 2 deletions src/tables/variable_fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ fn read_count(ctxt: &mut ReadCtxt<'_>) -> Result<u16, ParseError> {
}

mod packed_deltas {
use std::iter;

use crate::binary::read::ReadCtxt;
use crate::binary::{I16Be, I8};
Expand Down Expand Up @@ -633,7 +632,7 @@ mod packed_deltas {
let count = usize::from(control_byte & DELTA_RUN_COUNT_MASK) + 1; // value is stored - 1
deltas.reserve(count);
if (control_byte & DELTAS_ARE_ZERO) == DELTAS_ARE_ZERO {
deltas.extend(iter::repeat(0).take(count));
deltas.extend(std::iter::repeat_n(0, count));
} else if (control_byte & DELTAS_ARE_WORDS) == DELTAS_ARE_WORDS {
// Points are words (2 bytes)
let array = ctxt.read_array::<I16Be>(count)?;
Expand Down
2 changes: 1 addition & 1 deletion src/unicode/emoji_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
// yeslogic-ucd-generate 0.6.0 is available on crates.io.

pub const EMOJI_PRESENTATION: &'static ::ucd_trie::TrieSet = &::ucd_trie::TrieSet {
pub const EMOJI_PRESENTATION: &::ucd_trie::TrieSet = &::ucd_trie::TrieSet {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary - this file is generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thanks!

tree1_level1: &[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,
Expand Down
2 changes: 1 addition & 1 deletion src/unicode/mcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub enum ModifiedCombiningClass {

const X: ModifiedCombiningClass = ModifiedCombiningClass::NotReordered;
use ModifiedCombiningClass::*;
const MODIFIED_COMBINING_CLASS: &'static [ModifiedCombiningClass; 256] = &[
const MODIFIED_COMBINING_CLASS: &[ModifiedCombiningClass; 256] = &[
NotReordered, // NotReordered
Overlay, // Overlay
X, // CCC2
Expand Down