Skip to content

Commit b0d2c87

Browse files
authored
Clippy fixed
1 parent e7c9d2f commit b0d2c87

16 files changed

Lines changed: 39 additions & 37 deletions

File tree

examples/font2svg.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::too_many_arguments)]
2+
13
use base64::engine::general_purpose::STANDARD;
24

35
use std::io::Write;
@@ -167,7 +169,7 @@ fn process(args: Args) -> Result<(), Box<dyn std::error::Error>> {
167169
&mut svg,
168170
&mut path_buf,
169171
);
170-
} else if let Some(img) = face.glyph_raster_image(gid, std::u16::MAX) {
172+
} else if let Some(img) = face.glyph_raster_image(gid, u16::MAX) {
171173
svg.start_element("image");
172174
svg.write_attribute("x", &(x + 2.0 + img.x as f64));
173175
svg.write_attribute("y", &(y - img.y as f64));
@@ -208,7 +210,7 @@ fn process(args: Args) -> Result<(), Box<dyn std::error::Error>> {
208210

209211
println!("Elapsed: {}ms", now.elapsed().as_micros() as f64 / 1000.0);
210212

211-
std::fs::write(&args.svg_path, &svg.end_document())?;
213+
std::fs::write(&args.svg_path, svg.end_document())?;
212214

213215
Ok(())
214216
}

src/aat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'a> StateTable<'a> {
174174
#[inline]
175175
pub fn class(&self, glyph_id: GlyphId) -> Option<u8> {
176176
if glyph_id.0 == 0xFFFF {
177-
return Some(class::DELETED_GLYPH as u8);
177+
return Some(class::DELETED_GLYPH);
178178
}
179179

180180
let idx = glyph_id.0.checked_sub(self.first_glyph.0)?;
@@ -185,7 +185,7 @@ impl<'a> StateTable<'a> {
185185
#[inline]
186186
pub fn entry(&self, state: u16, mut class: u8) -> Option<StateEntry> {
187187
if u16::from(class) >= self.number_of_classes {
188-
class = class::OUT_OF_BOUNDS as u8;
188+
class = class::OUT_OF_BOUNDS;
189189
}
190190

191191
let entry_idx = self

src/delta_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a> DeltaSetIndexMap<'a> {
3636
let entry_size = ((entry_format >> 4) & 3) + 1;
3737
let inner_index_bit_count = u32::from((entry_format & 0xF) + 1);
3838

39-
s.advance(usize::try_from(entry_size).ok()? * usize::try_from(index).ok()?);
39+
s.advance(usize::from(entry_size) * usize::try_from(index).ok()?);
4040

4141
let mut n = 0u32;
4242
for b in s.read_bytes(usize::from(entry_size))? {

src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Font parsing starts with a [`Face`].
4343
#![allow(clippy::collapsible_else_if)]
4444
#![allow(clippy::field_reassign_with_default)]
4545
#![allow(clippy::upper_case_acronyms)]
46+
#![allow(clippy::bool_assert_comparison)]
4647

4748
#[cfg(feature = "std")]
4849
#[macro_use]
@@ -368,19 +369,19 @@ impl RectF {
368369
#[inline]
369370
fn new() -> Self {
370371
RectF {
371-
x_min: core::f32::MAX,
372-
y_min: core::f32::MAX,
373-
x_max: core::f32::MIN,
374-
y_max: core::f32::MIN,
372+
x_min: f32::MAX,
373+
y_min: f32::MAX,
374+
x_max: f32::MIN,
375+
y_max: f32::MIN,
375376
}
376377
}
377378

378379
#[inline]
379380
fn is_default(&self) -> bool {
380-
self.x_min == core::f32::MAX
381-
&& self.y_min == core::f32::MAX
382-
&& self.x_max == core::f32::MIN
383-
&& self.y_max == core::f32::MIN
381+
self.x_min == f32::MAX
382+
&& self.y_min == f32::MAX
383+
&& self.x_max == f32::MIN
384+
&& self.y_max == f32::MIN
384385
}
385386

386387
#[inline]

src/parser.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ impl TryNumFrom<f32> for i32 {
238238

239239
// We can't represent `MIN-1` exactly, but there's no fractional part
240240
// at this magnitude, so we can just use a `MIN` inclusive boundary.
241-
const MIN: f32 = core::i32::MIN as f32;
241+
const MIN: f32 = i32::MIN as f32;
242242
// We can't represent `MAX` exactly, but it will round up to exactly
243243
// `MAX+1` (a power of two) when we cast it.
244-
const MAX_P1: f32 = core::i32::MAX as f32;
244+
const MAX_P1: f32 = i32::MAX as f32;
245245
if v >= MIN && v < MAX_P1 {
246246
Some(v as i32)
247247
} else {
@@ -372,7 +372,7 @@ impl<'a, T: FromData> LazyArray16<'a, T> {
372372

373373
impl<'a, T: FromData + core::fmt::Debug + Copy> core::fmt::Debug for LazyArray16<'a, T> {
374374
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
375-
f.debug_list().entries(self.into_iter()).finish()
375+
f.debug_list().entries(*self).finish()
376376
}
377377
}
378378

@@ -522,7 +522,7 @@ impl<'a, T: FromData> LazyArray32<'a, T> {
522522

523523
impl<'a, T: FromData + core::fmt::Debug + Copy> core::fmt::Debug for LazyArray32<'a, T> {
524524
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
525-
f.debug_list().entries(self.into_iter()).finish()
525+
f.debug_list().entries(*self).finish()
526526
}
527527
}
528528

@@ -622,7 +622,7 @@ impl<'a, T: FromSlice<'a>> LazyOffsetArray16<'a, T> {
622622

623623
impl<'a, T: FromSlice<'a> + core::fmt::Debug + Copy> core::fmt::Debug for LazyOffsetArray16<'a, T> {
624624
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
625-
f.debug_list().entries(self.into_iter()).finish()
625+
f.debug_list().entries(*self).finish()
626626
}
627627
}
628628

src/tables/cff/index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn parse_index<'a, T: IndexSize>(s: &mut Stream<'a>) -> Option<Index<'a>> {
2424

2525
#[inline(never)]
2626
fn parse_index_impl<'a>(count: u32, s: &mut Stream<'a>) -> Option<Index<'a>> {
27-
if count == 0 || count == core::u32::MAX {
27+
if count == 0 || count == u32::MAX {
2828
return Some(Index::default());
2929
}
3030

@@ -53,7 +53,7 @@ pub fn skip_index<T: IndexSize>(s: &mut Stream) -> Option<()> {
5353

5454
#[inline(never)]
5555
fn skip_index_impl(count: u32, s: &mut Stream) -> Option<()> {
56-
if count == 0 || count == core::u32::MAX {
56+
if count == 0 || count == u32::MAX {
5757
return Some(());
5858
}
5959

src/tables/cmap/format2.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ impl<'a> Subtable2<'a> {
7272
pub fn glyph_index(&self, code_point: u32) -> Option<GlyphId> {
7373
// This subtable supports code points only in a u16 range.
7474
let code_point = u16::try_from(code_point).ok()?;
75-
76-
let code_point = code_point;
7775
let high_byte = code_point >> 8;
7876
let low_byte = code_point & 0x00FF;
7977

src/tables/colr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,8 +1897,8 @@ impl VariationData<'_> {
18971897

18981898
let variation_store = self.variation_store.as_ref().unwrap();
18991899

1900-
for i in 0..N {
1901-
deltas[i] = self
1900+
for (i, delta) in deltas.iter_mut().enumerate() {
1901+
*delta = self
19021902
.delta_map
19031903
.and_then(|d| d.map(var_index_base + i as u32))
19041904
.and_then(|d| variation_store.parse_delta(d.0, d.1, coordinates))

src/tables/cpal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a> Table<'a> {
4747
/// Returns the number of palettes.
4848
pub fn palettes(&self) -> NonZeroU16 {
4949
// Already checked during parsing.
50-
NonZeroU16::new(self.color_indices.len() as u16).unwrap()
50+
NonZeroU16::new(self.color_indices.len()).unwrap()
5151
}
5252

5353
/// Returns the color at the given index into the given palette.

src/tables/feat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a> FeatureNames<'a> {
117117

118118
impl<'a> core::fmt::Debug for FeatureNames<'a> {
119119
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
120-
f.debug_list().entries(self.into_iter()).finish()
120+
f.debug_list().entries(*self).finish()
121121
}
122122
}
123123

0 commit comments

Comments
 (0)