Skip to content

Commit

Permalink
ci: fix clippy lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
7sDream committed Nov 12, 2023
1 parent 8b8c361 commit ee53764
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/family.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'a> Family<'a> {
}
}

pub fn group_by_family_sort_by_name(faces: &Vec<FaceInfo>) -> Vec<Family<'_>> {
pub fn group_by_family_sort_by_name(faces: &[FaceInfo]) -> Vec<Family<'_>> {
let mut families = HashMap::new();

faces.iter().for_each(|face| {
Expand All @@ -56,5 +56,5 @@ pub fn group_by_family_sort_by_name(faces: &Vec<FaceInfo>) -> Vec<Family<'_>> {
family.faces.sort_unstable_by(|a, b| a.name.cmp(&b.name))
}

return families;
families
}
2 changes: 1 addition & 1 deletion src/loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn faces_contains(c: char) -> Vec<FaceInfo> {
}
}

return face.transpose();
face.transpose()
})
.filter_map(|f| f.ok())
.collect()
Expand Down
26 changes: 14 additions & 12 deletions src/preview/browser/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::iter::FromIterator;
use std::{fmt::Write, iter::FromIterator};

use super::SingleThreadServer;
use crate::family::Family;
Expand All @@ -43,21 +43,23 @@ impl<'a> Builder<'a> {
}

fn build_html(self, c: char) -> String {
let font_previews =
self.families.into_iter().fold(String::new(), |mut acc: String, family| {
write!(
&mut acc,
include_str!("statics/preview_block_template.html"),
char = c,
family = family,
)
.expect("write to string should always success");
acc
});

format!(
include_str!("statics/template.html"),
style = include_str!("statics/style.css"),
script = include_str!("statics/script.js"),
font_previews = self
.families
.into_iter()
.map(|family| {
format!(
include_str!("statics/preview_block_template.html"),
char = c,
family = family
)
})
.collect::<String>()
font_previews = font_previews,
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/preview/terminal/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct UI<'a> {

impl<'a: 'a> UI<'a> {
pub fn new(c: char, families: Vec<Family<'a>>) -> Option<Self> {
if families.len() > 0 {
if !families.is_empty() {
Some(Self { state: State::new(c, families), idle_redraw: 0 })
} else {
None
Expand Down
4 changes: 3 additions & 1 deletion src/rasterizer/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Metrics {
pub width: usize,
}

#[allow(dead_code)] // TODO: remove this
pub struct Bitmap {
pixel_mode: u8,
pitch: u32,
Expand All @@ -33,7 +34,8 @@ pub struct Bitmap {
}

impl Bitmap {
pub(super) fn new(_font_face: FontFace) -> Self {
#[allow(dead_code)] // remove this
pub fn new(_font_face: FontFace) -> Self {
// let face_rec = unsafe { &*font_face.face };
// let glyph = unsafe { &*face_rec.glyph };
// let left = glyph.bitmap_left;
Expand Down
1 change: 1 addition & 0 deletions src/rasterizer/font_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use crate::rasterizer::bitmap::Bitmap;

pub struct FontFace {
#[allow(dead_code)] // TODO: remove this
face: owned_ttf_parser::OwnedFace,
height: u32,
width: u32,
Expand Down

0 comments on commit ee53764

Please sign in to comment.