Skip to content

Commit 375c4d5

Browse files
committed
fix: replace try block with IIFE
1 parent 9a26bf9 commit 375c4d5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

anni/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(try_blocks)]
21
#![allow(incomplete_features)]
32
#![feature(impl_trait_in_assoc_type)]
43

anni/src/subcommands/workspace/fsck.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ fn handle_workspace_fsck(me: WorkspaceFsckAction) -> anyhow::Result<()> {
1919
let albums = workspace.scan()?;
2020
for album in albums {
2121
if let WorkspaceAlbumState::Dangling(album_path) = album.state {
22-
let result: anyhow::Result<()> = try {
22+
let result = || -> anyhow::Result<()> {
2323
let dot_album = album_path.join(".album");
2424
let real_path = workspace.controlled_album_path(&album.album_id, 2);
2525
if !real_path.exists() {
2626
fs::create_dir_all(&real_path)?;
2727
}
2828
fs::remove_file(&dot_album, false)?;
2929
fs::symlink_dir(&real_path, &dot_album)?;
30-
};
30+
Ok(())
31+
}();
3132

3233
if let Err(e) = result {
3334
log::error!(
@@ -44,7 +45,7 @@ fn handle_workspace_fsck(me: WorkspaceFsckAction) -> anyhow::Result<()> {
4445
let albums = workspace.scan()?;
4546
for album in albums {
4647
if let WorkspaceAlbumState::Garbage = album.state {
47-
let result: anyhow::Result<()> = try {
48+
let result = || -> anyhow::Result<()> {
4849
if let Ok(real_path) = workspace.get_album_controlled_path(&album.album_id) {
4950
// 1. remove garbage album directory
5051
fs::remove_dir_all(&real_path, true)?;
@@ -63,7 +64,8 @@ fn handle_workspace_fsck(me: WorkspaceFsckAction) -> anyhow::Result<()> {
6364
}
6465
}
6566
}
66-
};
67+
Ok(())
68+
}();
6769

6870
if let Err(e) = result {
6971
log::error!("Error while collecting garbage: {}", e);

0 commit comments

Comments
 (0)