Skip to content

Commit

Permalink
refactor: optimize based on cargo flippy
Browse files Browse the repository at this point in the history
collect to fold and format to write
  • Loading branch information
reminia committed Mar 29, 2024
1 parent 4d6a3db commit f5e0160
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "lf"
version = "0.1.0"
authors = ["[email protected]"]
description = "locate a file in file explorer"
repsoitory = "https://github.com/reminia/lf-rs"
repository = "https://github.com/reminia/lf-rs"
keywords = ["open", "focus"]
edition = "2021"

Expand Down
14 changes: 10 additions & 4 deletions src/macos.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::Write;
use std::process::Command;

fn apple_script(files: &[&str]) -> String {
Expand All @@ -8,10 +9,15 @@ fn apple_script(files: &[&str]) -> String {
{}\n\
select selects\n\
end tell",
files
.iter()
.map(|file| format!("set end of selects to POSIX file \"{}\" as alias\n", file))
.collect::<String>()
files.iter().fold(String::new(), |mut acc, file| {
writeln!(
&mut acc,
"set end of selects to POSIX file \"{}\" as alias",
file
)
.unwrap();
acc
})
)
}

Expand Down

0 comments on commit f5e0160

Please sign in to comment.