Skip to content

Commit

Permalink
fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturKovacs committed Jun 24, 2023
1 parent e6ea965 commit 2fda4af
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --features=networking -- -D warnings -A clippy::type_complexity -A clippy::needless_late_init -A clippy::question_mark
args: --all-targets --features=networking -- -D warnings -A clippy::type_complexity -A clippy::needless_late_init -A clippy::question_mark -A clippy::derivable-impls

build:
needs: rustfmt-clippy
Expand Down
2 changes: 1 addition & 1 deletion src/image_cache/pending_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl PendingRequests {

/// This returns all the ids including the finished item's
pub fn get_all_ids(&self) -> Vec<u32> {
self.by_id.iter().map(|(id, _)| *id).collect()
self.by_id.keys().copied().collect()
}

pub fn cancelled(&self, id: &u32) -> Option<bool> {
Expand Down
4 changes: 2 additions & 2 deletions src/playback_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl PlaybackManager {
};

let thread_count = match sys_info::cpu_num() {
Ok(value) => value.max(2).min(4),
Ok(value) => value.clamp(2, 4),
_ => 4,
};

Expand Down Expand Up @@ -411,7 +411,7 @@ impl<P: Playback> ImgSequencePlayer<P> {
let mut target = None;
for _ in 0..frame_step {
target = self.present_remaining.pop();
if target == None {
if target.is_none() {
// Restart
// WARNING we silently assume that the folder is fully
// filtered at this point.
Expand Down
10 changes: 4 additions & 6 deletions src/widgets/picture_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl PictureWidgetData {
let widget_phys_size = size * dpi_scale;
let fits_in_widget =
widget_phys_size.x >= img_phys_w && widget_phys_size.y >= img_pyhs_h;
self.img_pos = LogicalVector::new(size.x as f32 * 0.5, size.y as f32 * 0.5);
self.img_pos = LogicalVector::new(size.x * 0.5, size.y * 0.5);
if fits_in_widget && !stretch {
self.img_texel_size = 1.0;
} else {
Expand All @@ -211,10 +211,8 @@ impl PictureWidgetData {
let mut image_texel_size = (self.img_texel_size * delta).max(0.0);
if (image_texel_size - 1.0).abs() < 0.01 {
image_texel_size = 1.0;
} else if image_texel_size < MIN_ZOOM_FACTOR {
image_texel_size = MIN_ZOOM_FACTOR;
} else if image_texel_size > MAX_ZOOM_FACTOR {
image_texel_size = MAX_ZOOM_FACTOR;
} else {
image_texel_size = image_texel_size.clamp(MIN_ZOOM_FACTOR, MAX_ZOOM_FACTOR)
}
self.img_pos = (image_texel_size / self.img_texel_size) * (self.img_pos - anchor) + anchor;
self.img_texel_size = image_texel_size;
Expand Down Expand Up @@ -598,7 +596,7 @@ impl PictureWidget {
}
if triggered!(IMG_DEL_NAME) {
if let Some(path) = borrowed.playback_manager.shown_file_path() {
if let Err(e) = trash::delete(&path) {
if let Err(e) = trash::delete(path) {
eprintln!("Error while moving file '{:?}' to trash: {:?}", path, e);
}
if let Err(e) = borrowed.playback_manager.update_directory() {
Expand Down
4 changes: 2 additions & 2 deletions subcrates/gelatin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub trait WidgetData {
Length::Stretch { min, max } => {
let mut width = available_space.size.vec.x;
width -= self.placement().margin_left + self.placement().margin_right;
width = width.max(min).min(max);
width = width.clamp(min, max);
self.drawn_bounds().size.vec.x = width;
if width < max {
self.apply_horizontal_alignement(available_space, width);
Expand All @@ -141,7 +141,7 @@ pub trait WidgetData {
Length::Stretch { min, max } => {
let mut height = available_space.size.vec.y;
height -= self.placement().margin_top + self.placement().margin_bottom;
height = height.max(min).min(max);
height = height.clamp(min, max);
self.drawn_bounds().size.vec.y = height;
if height > max {
self.apply_vertical_alignement(available_space, height);
Expand Down
2 changes: 1 addition & 1 deletion subcrates/gelatin/src/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl Widget for Slider {
let relative_cursor_x =
event.cursor_pos.vec.x - borrowed.drawn_bounds.pos.vec.x;
let proportion =
(relative_cursor_x / borrowed.drawn_bounds.size.vec.x).max(0.0).min(1.0);
(relative_cursor_x / borrowed.drawn_bounds.size.vec.x).clamp(0.0, 1.0);
let stepsf = borrowed.steps as f32;
borrowed.value =
(proportion * (1.0 + 1.0 / stepsf) * (stepsf - 1.0)).floor() as u32;
Expand Down

0 comments on commit 2fda4af

Please sign in to comment.