From 419790fb74fbaf47d54519238b5a542a3875961e Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 28 Jun 2025 19:17:43 +0800 Subject: chore: clippy (#1334) --- src/utils/clipboard.rs | 4 ++-- src/utils/command.rs | 2 +- src/utils/crypto.rs | 2 +- src/utils/mod.rs | 2 +- src/utils/request.rs | 12 +++--------- src/utils/variables.rs | 2 +- 6 files changed, 9 insertions(+), 15 deletions(-) (limited to 'src/utils') diff --git a/src/utils/clipboard.rs b/src/utils/clipboard.rs index cb92bce..6b87ff7 100644 --- a/src/utils/clipboard.rs +++ b/src/utils/clipboard.rs @@ -8,7 +8,7 @@ static CLIPBOARD: std::sync::LazyLock anyhow::Result<()> { let encoded = BASE64.encode(text); - let seq = format!("\x1b]52;c;{}\x07", encoded); + let seq = format!("\x1b]52;c;{encoded}\x07"); // Write to stdout: if let Err(e) = std::io::Write::write_all(&mut std::io::stdout(), seq.as_bytes()) { return Err(anyhow::anyhow!("Failed to send OSC52 sequence").context(e)); @@ -35,7 +35,7 @@ pub fn set_text(text: &str) -> anyhow::Result<()> { match set_text_osc52(text) { Ok(()) => Ok(()), Err(osc_err) => Err(anyhow::anyhow!("No clipboard available") - .context(format!("Failed to copy (OSC52 error: {})", osc_err))), + .context(format!("Failed to copy (OSC52 error: {osc_err})"))), } } diff --git a/src/utils/command.rs b/src/utils/command.rs index 14a40a4..7d98504 100644 --- a/src/utils/command.rs +++ b/src/utils/command.rs @@ -175,7 +175,7 @@ pub fn append_to_shell_history(shell: &str, command: &str, exit_code: i32) -> io .create(true) .append(true) .open(&history_file)?; - writeln!(file, "{}", history_txt)?; + writeln!(file, "{history_txt}")?; } Ok(()) } diff --git a/src/utils/crypto.rs b/src/utils/crypto.rs index 9f0ee82..494ea84 100644 --- a/src/utils/crypto.rs +++ b/src/utils/crypto.rs @@ -17,7 +17,7 @@ pub fn hmac_sha256(key: &[u8], msg: &str) -> Vec { pub fn hex_encode(bytes: &[u8]) -> String { bytes .iter() - .fold(String::new(), |acc, b| acc + &format!("{:02x}", b)) + .fold(String::new(), |acc, b| acc + &format!("{b:02x}")) } pub fn encode_uri(uri: &str) -> String { diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 98f2da1..6c5b08a 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -162,7 +162,7 @@ pub fn indent_text(s: T, size: usize) -> String { let indent_str = " ".repeat(size); s.to_string() .split('\n') - .map(|line| format!("{}{}", indent_str, line)) + .map(|line| format!("{indent_str}{line}")) .collect::>() .join("\n") } diff --git a/src/utils/request.rs b/src/utils/request.rs index 8cee0a0..95c4f9c 100644 --- a/src/utils/request.rs +++ b/src/utils/request.rs @@ -131,7 +131,7 @@ pub async fn fetch_with_loaders( } let image_bytes = res.bytes().await?; let image_base64 = base64_encode(&image_bytes); - let contents = format!("data:{};base64,{}", content_type, image_base64); + let contents = format!("data:{content_type};base64,{image_base64}"); (contents, extension) } else { match loaders.get(&extension) { @@ -316,10 +316,7 @@ async fn crawl_gh_tree(start_url: &Url, exclude: &[String]) -> Result Result env::current_dir() .map(|v| v.display().to_string()) .unwrap_or_default(), - _ => format!("{{{{{}}}}}", key), + _ => format!("{{{{{key}}}}}"), } }) .to_string(); -- cgit v1.2.3