Skip to content

Commit 2d14df8

Browse files
committed
fix clippy
1 parent 852164c commit 2d14df8

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/shared/image_viewer.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ live_design! {
288288
}
289289

290290
/// Actions emitted by the `ImageViewer` widget.
291-
#[derive(Debug)]
291+
#[derive(Clone, Debug, DefaultNone)]
292292
pub enum ImageViewerAction {
293+
/// No action.
294+
None,
293295
/// Display the ImageViewer widget based on the LoadState.
294296
Show(LoadState),
295297
/// Close the ImageViewer widget.
@@ -443,30 +445,26 @@ impl Widget for ImageViewer {
443445
if let Event::Signal = event {
444446
let mut to_remove = false;
445447
if let Some((_background_task_id, receiver)) = &mut self.receiver {
446-
match receiver.try_recv() {
447-
Ok(image_buffer_res) => {
448-
match image_buffer_res {
449-
Ok(image_buffer) => {
450-
let rotated_image = self.view.rotated_image(ids!(rotated_image));
451-
let texture = image_buffer.into_new_texture(cx);
452-
rotated_image.set_texture(cx, Some(texture));
453-
to_remove = true;
454-
cx.action(ImageViewerAction::Show(LoadState::FinishedBackgroundDecoding));
455-
456-
}
457-
Err(error) => {
458-
let error = match error {
459-
ImageError::JpgDecode(_) | ImageError::PngDecode(_) => ImageViewerError::UnsupportedFormat,
460-
ImageError::EmptyData => ImageViewerError::BadData,
461-
ImageError::PathNotFound(_) => ImageViewerError::NotFound,
462-
ImageError::UnsupportedFormat => ImageViewerError::UnsupportedFormat,
463-
_ => ImageViewerError::BadData,
464-
};
465-
cx.action(ImageViewerAction::Show(LoadState::Error(error)));
466-
}
448+
if let Ok(image_buffer) = receiver.try_recv() {
449+
match image_buffer {
450+
Ok(image_buffer) => {
451+
let rotated_image = self.view.rotated_image(ids!(rotated_image));
452+
let texture = image_buffer.into_new_texture(cx);
453+
rotated_image.set_texture(cx, Some(texture));
454+
to_remove = true;
455+
cx.action(ImageViewerAction::Show(LoadState::FinishedBackgroundDecoding));
456+
}
457+
Err(error) => {
458+
let error = match error {
459+
ImageError::JpgDecode(_) | ImageError::PngDecode(_) => ImageViewerError::UnsupportedFormat,
460+
ImageError::EmptyData => ImageViewerError::BadData,
461+
ImageError::PathNotFound(_) => ImageViewerError::NotFound,
462+
ImageError::UnsupportedFormat => ImageViewerError::UnsupportedFormat,
463+
_ => ImageViewerError::BadData,
464+
};
465+
cx.action(ImageViewerAction::Show(LoadState::Error(error)));
467466
}
468467
}
469-
Err(_) => {}
470468
}
471469
}
472470
if to_remove {
@@ -540,7 +538,7 @@ impl ImageViewer {
540538
// Clear the rotated image texture with a white background
541539
if let Ok(image_buffer) = ImageBuffer::new(&[255], 1, 1) {
542540
let texture = image_buffer.into_new_texture(cx);
543-
let _ = self.view.rotated_image(ids!(rotated_image)).set_texture(cx, Some(texture));
541+
self.view.rotated_image(ids!(rotated_image)).set_texture(cx, Some(texture));
544542
self.view.rotated_image(ids!(rotated_image)).redraw(cx);
545543
}
546544
self.animator_cut(cx, ids!(mode.upright));
@@ -727,7 +725,7 @@ impl ImageViewerRef {
727725
}
728726

729727
/// Represents the possible states of an image load operation.
730-
#[derive(Debug,)]
728+
#[derive(Debug, Clone)]
731729
pub enum LoadState {
732730
/// The image is currently being loaded with its loading image texture and its image size.
733731
/// This texture is usually the image texture that's being selected.

0 commit comments

Comments
 (0)