Skip to content

Commit 02c95be

Browse files
committed
Fix clippy warnings
1 parent 9a9bdf4 commit 02c95be

7 files changed

Lines changed: 26 additions & 25 deletions

File tree

bdf-parser/src/glyph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Glyph {
8080
return None;
8181
}
8282

83-
let bytes_per_row = (width + 7) / 8;
83+
let bytes_per_row = width.div_ceil(8);
8484
let byte_offset = x / 8;
8585
let bit_mask = 0x80 >> (x % 8);
8686

bdf-parser/src/properties.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl Properties {
157157
// Convert vector of properties into a HashMap
158158
let properties = properties
159159
.map(|p| p.iter().cloned().collect())
160-
.unwrap_or_else(HashMap::new);
160+
.unwrap_or_default();
161161

162162
Self { properties }
163163
},

eg-bdf-examples/examples/hello.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use eg_bdf::{BdfGlyph, BdfTextStyle};
1+
use eg_bdf::BdfTextStyle;
22
use embedded_graphics::{
33
mono_font::MonoTextStyle,
44
pixelcolor::Rgb888,

eg-font-converter/src/eg_bdf_font.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl EgBdfOutput {
105105
});
106106

107107
let comments = self.font.comments.iter().map(|comment| {
108-
let comment = format!(" {}", comment);
108+
let comment = format!(" {comment}");
109109
quote!(
110110
#[doc = #comment]
111111
)
@@ -157,8 +157,8 @@ impl EgBdfOutput {
157157
pub fn save<P: AsRef<Path>>(&self, output_directory: P) -> io::Result<()> {
158158
let output_directory = output_directory.as_ref();
159159

160-
fs::write(self.font.rust_file_path(output_directory), &self.rust())?;
161-
fs::write(self.font.data_file_path(output_directory), &self.data())?;
160+
fs::write(self.font.rust_file_path(output_directory), self.rust())?;
161+
fs::write(self.font.data_file_path(output_directory), self.data())?;
162162

163163
Ok(())
164164
}

eg-font-converter/src/lib.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@
1717
//! ```no_run
1818
//! use eg_font_converter::{FontConverter, Mapping};
1919
//!
20-
//! fn main() {
21-
//! let out_dir = std::env::var_os("OUT_DIR").unwrap();
20+
//! let out_dir = std::env::var_os("OUT_DIR").unwrap();
2221
//!
23-
//! let font_6x10 = FontConverter::new("examples/6x10.bdf", "FONT_6X10_AZ")
24-
//! .glyphs('A'..='Z')
25-
//! .convert_mono_font()
26-
//! .unwrap();
22+
//! let font_6x10 = FontConverter::new("examples/6x10.bdf", "FONT_6X10_AZ")
23+
//! .glyphs('A'..='Z')
24+
//! .convert_mono_font()
25+
//! .unwrap();
2726
//!
28-
//! font_6x10.save(&out_dir).unwrap();
29-
//! }
27+
//! font_6x10.save(&out_dir).unwrap();
3028
//! ```
3129
//!
3230
//! And then use the [`include!`] macro to import the generated code into your project:
@@ -264,12 +262,13 @@ impl<'a> FontConverter<'a> {
264262
let bdf = match &self.bdf {
265263
FileOrData::File(file) => {
266264
let data = std::fs::read(file)
267-
.with_context(|| format!("couldn't read BDF file from {:?}", file))?;
265+
.with_context(|| format!("couldn't read BDF file from {file:?}"))?;
268266

269-
ParserBdfFont::parse(&data).with_context(|| format!("couldn't parse BDF file"))?
267+
ParserBdfFont::parse(&data)
268+
.with_context(|| "couldn't parse BDF file".to_string())?
270269
}
271270
FileOrData::Data(data) => {
272-
ParserBdfFont::parse(data).with_context(|| format!("couldn't parse BDF file"))?
271+
ParserBdfFont::parse(data).with_context(|| "couldn't parse BDF file".to_string())?
273272
}
274273
};
275274

@@ -439,7 +438,7 @@ impl Font {
439438
}
440439

441440
fn data_file_path(&self, output_directory: &Path) -> PathBuf {
442-
output_directory.join(&self.data_file())
441+
output_directory.join(self.data_file())
443442
}
444443
}
445444

@@ -518,8 +517,10 @@ pub enum Visibility {
518517
PubIn(String),
519518
}
520519

521-
impl ToString for Visibility {
522-
fn to_string(&self) -> String {
520+
impl Visibility {
521+
// TODO: is Visibility even used anymore?
522+
#[allow(unused)]
523+
fn to_rust(&self) -> String {
523524
match self {
524525
Visibility::Private => "",
525526
Visibility::Pub => "pub",

eg-font-converter/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn main() {
121121
}
122122

123123
if let Err(e) = convert(&args) {
124-
eprintln!("Error: {:#}", e);
124+
eprintln!("Error: {e:#}");
125125
std::process::exit(1);
126126
}
127127
}

eg-font-converter/src/mono_font.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl MonoFontOutput {
3838

3939
let glyphs_per_row = 16; //TODO: make configurable
4040
let columns = glyphs_per_row; // TODO: allow smaller column count
41-
let rows = (font.glyphs.len() + (glyphs_per_row - 1)) / glyphs_per_row;
41+
let rows = font.glyphs.len().div_ceil(glyphs_per_row);
4242

4343
let character_size = bdf.bounding_box().size;
4444
let character_spacing = 0;
@@ -149,7 +149,7 @@ impl MonoFontOutput {
149149
};
150150

151151
let comments = self.font.comments.iter().map(|comment| {
152-
let comment = format!(" {}", comment);
152+
let comment = format!(" {comment}");
153153
quote!(
154154
#[doc = #comment]
155155
)
@@ -193,8 +193,8 @@ impl MonoFontOutput {
193193
pub fn save<P: AsRef<Path>>(&self, output_directory: P) -> io::Result<()> {
194194
let output_directory = output_directory.as_ref();
195195

196-
fs::write(self.font.rust_file_path(output_directory), &self.rust())?;
197-
fs::write(self.font.data_file_path(output_directory), &self.data())?;
196+
fs::write(self.font.rust_file_path(output_directory), self.rust())?;
197+
fs::write(self.font.data_file_path(output_directory), self.data())?;
198198

199199
Ok(())
200200
}

0 commit comments

Comments
 (0)