Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Sep 14, 2023
1 parent 1e7b0a7 commit d02bcb9
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 16 deletions.
6 changes: 3 additions & 3 deletions vsvg-core/src/document/document.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::{Layer, PageSize, Path};
use super::{DocumentMetadata, DocumentTrait, FlattenedDocument, LayerID};
use crate::{Layer, PageSize, Path, Transforms};
use std::collections::BTreeMap;

#[derive(Default, Clone, Debug)]
Expand Down Expand Up @@ -80,7 +80,7 @@ impl Document {
#[cfg(test)]
mod test {
use super::*;
use crate::Layer;
use crate::{Layer, LayerTrait};

#[test]
fn test_document_bounds() {
Expand Down
5 changes: 3 additions & 2 deletions vsvg-core/src/document/flattened_document.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::*;
use crate::{FlattenedLayer, FlattenedPath, Polyline};
use super::{DocumentMetadata, DocumentTrait, LayerID};
use crate::{FlattenedLayer, FlattenedPath, Polyline, Transforms};
use std::collections::BTreeMap;

#[derive(Default, Clone, Debug)]
pub struct FlattenedDocument {
Expand Down
1 change: 1 addition & 0 deletions vsvg-core/src/document/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{LayerTrait, PathDataTrait, PathTrait, Transforms};
use std::collections::BTreeMap;

#[allow(clippy::module_inception)]
mod document;
mod flattened_document;
mod metadata;
Expand Down
4 changes: 2 additions & 2 deletions vsvg-core/src/layer/flattened_layer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::{FlattenedPath, Polyline};
use super::{LayerMetadata, LayerTrait};
use crate::{FlattenedPath, Polyline, Transforms};

#[derive(Default, Clone, Debug)]
pub struct FlattenedLayer {
Expand Down
4 changes: 2 additions & 2 deletions vsvg-core/src/layer/layer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::{FlattenedPath, Path, PathTrait};
use super::{FlattenedLayer, LayerMetadata, LayerTrait, Transforms};
use crate::{FlattenedPath, Path, Point};

#[derive(Default, Clone, Debug)]
pub struct Layer {
Expand Down
3 changes: 2 additions & 1 deletion vsvg-core/src/layer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod flattened_layer;
#[allow(clippy::module_inception)]
mod layer;
mod metadata;

Expand Down Expand Up @@ -42,7 +43,7 @@ pub trait LayerTrait<P: PathTrait<D>, D: PathDataTrait>: Default + Transforms {
}

let mut new_paths = Vec::with_capacity(self.paths().len());
let mut index = builder.build(&self.paths());
let mut index = builder.build(self.paths());

let mut pos = Point::ZERO;
while let Some((path_item, reverse)) = index.pop_nearest(&pos) {
Expand Down
1 change: 1 addition & 0 deletions vsvg-core/src/optimization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ impl Layer {
self.sort_with_builder(IndexBuilder::default().flip(flip));
}

#[allow(clippy::missing_panics_doc)]
pub fn sort_with_builder(&mut self, builder: IndexBuilder) {
if self.paths.len() <= 1 {
return;
Expand Down
5 changes: 4 additions & 1 deletion vsvg-core/src/path/flattened_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,25 @@ use kurbo::Affine;
pub struct Polyline(Vec<Point>);

impl Polyline {
#[must_use]
pub fn new(points: Vec<Point>) -> Self {
Self(points)
}

#[must_use]
pub fn points(&self) -> &[Point] {
&self.0
}

#[must_use]
pub fn points_mut(&mut self) -> &mut Vec<Point> {
&mut self.0
}
}

impl Transforms for Polyline {
fn transform(&mut self, affine: &Affine) {
for point in self.points_mut().iter_mut() {
for point in self.points_mut() {
*point = *affine * *point;
}
}
Expand Down
1 change: 1 addition & 0 deletions vsvg-core/src/path/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod flattened_path;
mod metadata;
#[allow(clippy::module_inception)]
mod path;
mod point;

Expand Down
3 changes: 2 additions & 1 deletion vsvg-core/src/path_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl<'a, P: PathTrait<D>, D: PathDataTrait> PathIndex<'a, P, D> {

// update k-d tree
self.tree = KdTree::new(2);
for (idx, path_item) in self.paths.iter() {
for (idx, path_item) in &self.paths {
if let Some(ref start) = path_item.start {
if self.settings.flip {
if let Some(ref end) = path_item.end {
Expand Down Expand Up @@ -204,6 +204,7 @@ impl<'a, P: PathTrait<D>, D: PathDataTrait> PathIndex<'a, P, D> {
///
/// This function may return `None` even if the `PathIndex` is not empty, as some paths may not
/// be indexed.
#[allow(clippy::missing_panics_doc)]
pub fn pop_nearest(&mut self, point: &Point) -> Option<(PathItem<P, D>, bool)> {
if self.reindex_agent.should_reindex() {
self.reindex();
Expand Down
3 changes: 1 addition & 2 deletions vsvg-core/src/svg_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use std::fs;
use std::path;

use crate::{
Color, Document, DocumentTrait, Layer, LayerID, LayerTrait, PageSize, Path, PathMetadata,
PathTrait,
Color, Document, DocumentTrait, Layer, LayerID, LayerTrait, PageSize, Path, PathTrait,
};

use usvg::utils::view_box_to_transform;
Expand Down
2 changes: 1 addition & 1 deletion vsvg-multi/src/multi_viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl MultiViewer {
impl eframe::App for MultiViewer {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
// handle input
if !ctx.wants_keyboard_input() {}
//if !ctx.wants_keyboard_input() {}

egui::SidePanel::left("left_panel").show(ctx, |ui| {
ui.input(|i| {
Expand Down
2 changes: 2 additions & 0 deletions vsvg-viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use std::error::Error;
use std::sync::Arc;
use vsvg_core::Document;

/// Show a document in a window.
#[allow(clippy::missing_panics_doc)]
pub fn show(document: &Document) -> Result<(), Box<dyn Error>> {
let native_options = eframe::NativeOptions::default();
let document_data = Arc::new(DocumentData::new(document));
Expand Down
1 change: 0 additions & 1 deletion vsvg/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::cli::{CommandDesc, CommandValue};
use clap::{arg, value_parser, Arg, Id};
use std::collections::HashMap;
use std::io::Write;
use vsvg_core::{DocumentTrait, IndexBuilder, Transforms};

// https://stackoverflow.com/a/38361018/229511
Expand Down

0 comments on commit d02bcb9

Please sign in to comment.