Skip to content

Commit bbb0f3d

Browse files
committed
tauri: refactor: fix some clippy warnings
1 parent 8e55087 commit bbb0f3d

File tree

14 files changed

+36
-42
lines changed

14 files changed

+36
-42
lines changed

packages/target-tauri/crates/user-notify/examples/test.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async fn main() -> anyhow::Result<()> {
6161
notification = notification
6262
.title("my title2")
6363
.body("my body2")
64-
.set_thread_id(&format!("thread-id"));
64+
.set_thread_id("thread-id");
6565

6666
log::debug!("4");
6767
manager.send_notification(notification).await?;
@@ -73,7 +73,7 @@ async fn main() -> anyhow::Result<()> {
7373
let notification = user_notify::NotificationBuilder::new()
7474
.title("my title")
7575
.body("my body")
76-
.set_thread_id(&format!("thread-id"))
76+
.set_thread_id("thread-id")
7777
.set_user_info(info)
7878
.set_category_id("my.app.123.textinput");
7979

@@ -90,8 +90,7 @@ async fn main() -> anyhow::Result<()> {
9090
assert!(
9191
active
9292
.iter()
93-
.find(|handle| handle.get_user_info().contains_key("hey"))
94-
.is_some()
93+
.any(|handle| handle.get_user_info().contains_key("hey"))
9594
);
9695

9796
let _ = ctrl_c().await;

packages/target-tauri/src-tauri/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,20 @@ fn get_git_ref() -> String {
114114
{
115115
git_branch = git_symbolic_ref
116116
.split('/')
117-
.last()
117+
.next_back()
118118
.unwrap_or("main")
119119
.to_string();
120-
println!("{} {}", git_symbolic_ref, git_branch);
120+
println!("{git_symbolic_ref} {git_branch}");
121121
} else {
122122
git_branch = gather_process_stdout("git", &["symbolic-ref", "HEAD"])
123-
.map(|r| r.split('/').last().unwrap_or("main").to_owned())
123+
.map(|r| r.split('/').next_back().unwrap_or("main").to_owned())
124124
.unwrap_or("main".to_owned())
125125
.to_string();
126126
}
127127

128128
if git_branch == "main" {
129129
git_describe
130130
} else {
131-
format!("{}-{}", git_describe, git_branch)
131+
format!("{git_describe}-{git_branch}")
132132
}
133133
}

packages/target-tauri/src-tauri/src/blobs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub(crate) fn delta_blobs_protocol<R: tauri::Runtime>(
8787
// trace!("file_path: {file_path:?}");
8888

8989
assert_eq!(
90-
file_path.components().last().unwrap().as_os_str(),
90+
file_path.components().next_back().unwrap().as_os_str(),
9191
file_name
9292
);
9393
assert!(file_path

packages/target-tauri/src-tauri/src/html_window/email_scheme.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ pub(crate) fn email_protocol<R: tauri::Runtime>(
3737
let webview_label = ctx.webview_label();
3838
if !webview_label.starts_with("html-window:") || !webview_label.ends_with("-mail") {
3939
error!(
40-
"prevented other window from accessing email:// scheme (webview label: {})",
41-
webview_label
40+
"prevented other window from accessing email:// scheme (webview label: {webview_label})"
4241
);
4342
return;
4443
}

packages/target-tauri/src-tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const DEFAULT_WINDOW_HEIGHT: f64 = 600.;
7878
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
7979
#[tauri::command]
8080
fn greet(name: &str) -> String {
81-
format!("Hello, {}! You've been greeted from Rust!", name)
81+
format!("Hello, {name}! You've been greeted from Rust!")
8282
}
8383

8484
#[tauri::command]

packages/target-tauri/src-tauri/src/menus/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub(crate) fn handle_menu_event(app: &AppHandle, event: MenuEvent) {
5353
let app = app.clone();
5454
let future = spawn(async move {
5555
if let Err(e) = handle_event(&app, event).await {
56-
log::error!("{:?}", e);
56+
log::error!("{e:?}");
5757
}
5858
});
5959
drop(future);

packages/target-tauri/src-tauri/src/state/tray_manager.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,20 @@ impl TrayManager {
4242
tray.set_visible(false)?;
4343
}
4444
}
45-
} else {
46-
if currently_active != wanted_state {
47-
if wanted_state {
48-
let tray = build_tray_icon(app)?;
49-
let previous = self.tray.write().await.replace(tray);
50-
assert!(previous.is_none());
51-
self.update_badge(app).await?;
45+
} else if currently_active != wanted_state {
46+
if wanted_state {
47+
let tray = build_tray_icon(app)?;
48+
let previous = self.tray.write().await.replace(tray);
49+
assert!(previous.is_none());
50+
self.update_badge(app).await?;
51+
} else {
52+
let previous = self.tray.write().await.take();
53+
if let Some(tray) = previous {
54+
tray.set_visible(false)?;
55+
let tray_option = app.remove_tray_by_id(tray.id());
56+
drop(tray_option);
5257
} else {
53-
let previous = self.tray.write().await.take();
54-
if let Some(tray) = previous {
55-
tray.set_visible(false)?;
56-
let tray_option = app.remove_tray_by_id(tray.id());
57-
drop(tray_option);
58-
} else {
59-
unreachable!()
60-
}
58+
unreachable!()
6159
}
6260
}
6361
}

packages/target-tauri/src-tauri/src/state/webxdc_instances.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl WebxdcInstancesState {
8686
self.inner
8787
.read()
8888
.await
89-
.iter()
90-
.map(|(window_label, _)| window_label.to_owned())
89+
.keys()
90+
.map(|window_label| window_label.to_owned())
9191
.collect()
9292
}
9393
pub(crate) async fn get_all_webxdc_windows_for_account_id(

packages/target-tauri/src-tauri/src/temp_file.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async fn create_tmp_file(app: &AppHandle, name: &str) -> Result<(File, PathBuf),
6565
.ok_or(Error::InvalidFileName)?;
6666
let file_path = dir.join(file_name);
6767

68-
assert!(file_path.components().last().unwrap().as_os_str() == file_name);
68+
assert!(file_path.components().next_back().unwrap().as_os_str() == file_name);
6969
assert!(file_path
7070
.components()
7171
.rev()
@@ -109,7 +109,7 @@ async fn delete_tmp_file(app: &AppHandle, path: SafePathBuf) -> Result<(), Error
109109
// create tmp folder
110110
pub(crate) async fn create_tmp_folder(app: &AppHandle) -> Result<(), Error> {
111111
let tmp_folder = get_temp_folder_path(app)?;
112-
info!("using temp folder at {:?}", tmp_folder);
112+
info!("using temp folder at {tmp_folder:?}");
113113
create_dir_all(get_temp_folder_path(app)?).await?;
114114
Ok(())
115115
}
@@ -119,7 +119,7 @@ pub(crate) async fn create_tmp_folder(app: &AppHandle) -> Result<(), Error> {
119119
pub(crate) async fn clear_tmp_folder(app: &AppHandle) -> Result<(), Error> {
120120
let tmp_folder = get_temp_folder_path(app)?;
121121
if !exists(&tmp_folder)? {
122-
warn!("tmp folder does not exist at: {:?}", tmp_folder);
122+
warn!("tmp folder does not exist at: {tmp_folder:?}");
123123
return Ok(());
124124
}
125125

packages/target-tauri/src-tauri/src/themes/themes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl ThemeMetadata {
8383
) {
8484
map.insert(key, value);
8585
} else {
86-
log::warn!("can't parse css variable {:?}", captures);
86+
log::warn!("can't parse css variable {captures:?}");
8787
continue;
8888
}
8989
}

0 commit comments

Comments
 (0)