src: Format let-else statements
This commit is contained in:
parent
6297dcf54b
commit
06d688e79e
6 changed files with 48 additions and 16 deletions
|
|
@ -304,7 +304,9 @@ impl TiledImage {
|
|||
}
|
||||
|
||||
pub fn contains(&self, zoom: f64, coordinates: Coordinates) -> bool {
|
||||
let Some(tile_layer) = self.tile_layers.get(&zoom_to_level(zoom)) else { return false };
|
||||
let Some(tile_layer) = self.tile_layers.get(&zoom_to_level(zoom)) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
tile_layer.tiles.contains_key(&coordinates)
|
||||
}
|
||||
|
|
@ -483,7 +485,9 @@ impl Tiling {
|
|||
for x in (x0 as i32..=x1 as i32).step_by(self.tile_width.into()) {
|
||||
for y in (y0 as i32..=y1 as i32).step_by(self.tile_height.into()) {
|
||||
let area = graphene::Rect::new(x as f32, y as f32, tile_width, tile_height);
|
||||
let Some(restricted_area) = area.restrict(original_width, original_height) else { continue; };
|
||||
let Some(restricted_area) = area.restrict(original_width, original_height) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let tile = TileInstructions {
|
||||
tiling: *self,
|
||||
|
|
|
|||
|
|
@ -242,7 +242,9 @@ impl LpFileModel {
|
|||
}
|
||||
|
||||
fn is_image_file(file: &gio::File) -> bool {
|
||||
let Ok(info) = util::query_attributes(file, vec![gio::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE]) else {
|
||||
let Ok(info) =
|
||||
util::query_attributes(file, vec![gio::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE])
|
||||
else {
|
||||
log::warn!("Could not query file info: {}", file.uri());
|
||||
return false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -125,11 +125,17 @@ pub async fn untrash(path: &Path) -> anyhow::Result<()> {
|
|||
.next_files_future(1, glib::Priority::default())
|
||||
.await
|
||||
{
|
||||
let Some(file_info) = info.first()
|
||||
else { break; };
|
||||
let Some(file_info) = info.first() else {
|
||||
break;
|
||||
};
|
||||
|
||||
let Some(original_path) = file_info.attribute_byte_string(gio::FILE_ATTRIBUTE_TRASH_ORIG_PATH).as_ref().map(PathBuf::from)
|
||||
else { break; };
|
||||
let Some(original_path) = file_info
|
||||
.attribute_byte_string(gio::FILE_ATTRIBUTE_TRASH_ORIG_PATH)
|
||||
.as_ref()
|
||||
.map(PathBuf::from)
|
||||
else {
|
||||
break;
|
||||
};
|
||||
|
||||
if original_path == path {
|
||||
let trash_file = trash.child(file_info.name());
|
||||
|
|
@ -143,7 +149,9 @@ pub async fn untrash(path: &Path) -> anyhow::Result<()> {
|
|||
}
|
||||
|
||||
// Construct new name of the form "<filename> (i).<ext>"
|
||||
let Some(path) = original_file.path() else { bail!("File without path") };
|
||||
let Some(path) = original_file.path() else {
|
||||
bail!("File without path")
|
||||
};
|
||||
let mut name = path
|
||||
.file_stem()
|
||||
.map(|x| x.to_os_string())
|
||||
|
|
|
|||
|
|
@ -1805,10 +1805,18 @@ impl LpImage {
|
|||
let mut bad_contrast = 0;
|
||||
'img: loop {
|
||||
for _ in 0..texture.width() {
|
||||
let Some(r) = bytes_iter.next() else { break 'img; };
|
||||
let Some(g) = bytes_iter.next() else { break 'img; };
|
||||
let Some(b) = bytes_iter.next() else { break 'img; };
|
||||
let Some(a) = bytes_iter.next() else { break 'img; };
|
||||
let Some(r) = bytes_iter.next() else {
|
||||
break 'img;
|
||||
};
|
||||
let Some(g) = bytes_iter.next() else {
|
||||
break 'img;
|
||||
};
|
||||
let Some(b) = bytes_iter.next() else {
|
||||
break 'img;
|
||||
};
|
||||
let Some(a) = bytes_iter.next() else {
|
||||
break 'img;
|
||||
};
|
||||
|
||||
if *a < 255 {
|
||||
has_transparency = true;
|
||||
|
|
|
|||
|
|
@ -416,7 +416,10 @@ impl LpImageView {
|
|||
|
||||
fn scroll_sliding_view(&self, file: &gio::File) {
|
||||
let Some(current_page) = self.sliding_view().pages().remove(&file.uri()) else {
|
||||
log::error!("Current path not available in sliding_view for scrolling: {}", file.uri());
|
||||
log::error!(
|
||||
"Current path not available in sliding_view for scrolling: {}",
|
||||
file.uri()
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -482,7 +485,9 @@ impl LpImageView {
|
|||
|
||||
/// Handle files are added or removed from directory
|
||||
fn model_content_changed_cb(&self) {
|
||||
let Some(current_file) = self.current_file() else { return; };
|
||||
let Some(current_file) = self.current_file() else {
|
||||
return;
|
||||
};
|
||||
|
||||
// LpImage did not get the update yet
|
||||
// Update will be handled by current_image_path_changed
|
||||
|
|
|
|||
|
|
@ -550,8 +550,13 @@ impl LpWindow {
|
|||
|
||||
async fn trash(&self) {
|
||||
let image_view = self.image_view();
|
||||
let (Some(file), Some(path)) = (image_view.current_file(), image_view.current_file().and_then(|x| x.path()))
|
||||
else { log::error!("No file to trash"); return; };
|
||||
let (Some(file), Some(path)) = (
|
||||
image_view.current_file(),
|
||||
image_view.current_file().and_then(|x| x.path()),
|
||||
) else {
|
||||
log::error!("No file to trash");
|
||||
return;
|
||||
};
|
||||
|
||||
let result = file.trash_future(glib::Priority::default()).await;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue