diff --git a/Cargo.lock b/Cargo.lock index 713ba8df..f87219c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2421,12 +2421,9 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "slab" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" [[package]] name = "smallvec" diff --git a/yazi-adapter/src/lib.rs b/yazi-adapter/src/lib.rs index 42da957c..3decaa14 100644 --- a/yazi-adapter/src/lib.rs +++ b/yazi-adapter/src/lib.rs @@ -1,4 +1,4 @@ -#![allow(clippy::unit_arg, clippy::option_map_unit_fn)] +#![allow(clippy::option_map_unit_fn, clippy::unit_arg)] yazi_macro::mod_pub!(drivers); diff --git a/yazi-adapter/src/mux.rs b/yazi-adapter/src/mux.rs index 07eb6001..167a2b5f 100644 --- a/yazi-adapter/src/mux.rs +++ b/yazi-adapter/src/mux.rs @@ -1,3 +1,5 @@ +use std::borrow::Cow; + use anyhow::Result; use tracing::error; use yazi_macro::time; @@ -8,14 +10,14 @@ use crate::{CLOSE, ESCAPE, Emulator, START, TMUX}; pub struct Mux; impl Mux { - pub fn csi(s: &str) -> std::borrow::Cow { + pub fn csi(s: &str) -> Cow<'_, str> { if TMUX.get() { - std::borrow::Cow::Owned(format!( + Cow::Owned(format!( "{START}{}{CLOSE}", s.trim_start_matches('\x1b').replace('\x1b', ESCAPE.get()), )) } else { - std::borrow::Cow::Borrowed(s) + Cow::Borrowed(s) } } diff --git a/yazi-cli/src/args.rs b/yazi-cli/src/args.rs index 8100e4dc..684af4dd 100644 --- a/yazi-cli/src/args.rs +++ b/yazi-cli/src/args.rs @@ -175,7 +175,7 @@ macro_rules! impl_pub_body { ($name:ident) => { impl $name { #[allow(dead_code)] - pub(super) fn body(&self) -> Result> { + pub(super) fn body(&self) -> Result> { Ok(if let Some(json) = &self.json { json.into() } else if let Some(str) = &self.str { diff --git a/yazi-config/src/keymap/chord.rs b/yazi-config/src/keymap/chord.rs index 344fd788..f2e39766 100644 --- a/yazi-config/src/keymap/chord.rs +++ b/yazi-config/src/keymap/chord.rs @@ -38,11 +38,11 @@ impl Chord { .into_owned() } - pub fn desc(&self) -> Option> { + pub fn desc(&self) -> Option> { self.desc.as_ref().map(|s| RE.get_or_init(|| Regex::new(r"\s+").unwrap()).replace_all(s, " ")) } - pub fn desc_or_run(&self) -> Cow { self.desc().unwrap_or_else(|| self.run().into()) } + pub fn desc_or_run(&self) -> Cow<'_, str> { self.desc().unwrap_or_else(|| self.run().into()) } pub fn contains(&self, s: &str) -> bool { let s = s.to_lowercase(); diff --git a/yazi-core/src/tab/commands/copy.rs b/yazi-core/src/tab/commands/copy.rs index 6f528279..9c5d396f 100644 --- a/yazi-core/src/tab/commands/copy.rs +++ b/yazi-core/src/tab/commands/copy.rs @@ -75,7 +75,7 @@ impl From<&str> for Separator { } impl Separator { - fn transform + ?Sized>(self, p: &T) -> Cow { + fn transform + ?Sized>(self, p: &T) -> Cow<'_, OsStr> { #[cfg(windows)] if self == Self::Unix { return match yazi_fs::backslash_to_slash(p.as_ref()) { diff --git a/yazi-fm/src/term.rs b/yazi-fm/src/term.rs index 2b31a3dd..0c25e74d 100644 --- a/yazi-fm/src/term.rs +++ b/yazi-fm/src/term.rs @@ -110,7 +110,7 @@ impl Term { std::process::exit(f()); } - pub(super) fn draw(&mut self, f: impl FnOnce(&mut Frame)) -> io::Result { + pub(super) fn draw(&mut self, f: impl FnOnce(&mut Frame)) -> io::Result> { let last = self.inner.draw(f)?; self.last_area = last.area; @@ -118,7 +118,10 @@ impl Term { Ok(last) } - pub(super) fn draw_partial(&mut self, f: impl FnOnce(&mut Frame)) -> io::Result { + pub(super) fn draw_partial( + &mut self, + f: impl FnOnce(&mut Frame), + ) -> io::Result> { self.inner.draw(|frame| { let buffer = frame.buffer_mut(); for y in self.last_area.top()..self.last_area.bottom() { diff --git a/yazi-plugin/src/elements/table.rs b/yazi-plugin/src/elements/table.rs index cd591b15..a7006b3c 100644 --- a/yazi-plugin/src/elements/table.rs +++ b/yazi-plugin/src/elements/table.rs @@ -48,7 +48,7 @@ impl Table { table.into_lua(lua) } - pub fn selected_cell(&self) -> Option<&ratatui::text::Text> { + pub fn selected_cell(&self) -> Option<&ratatui::text::Text<'_>> { let row = &self.rows[self.selected()?]; let col = self.state.selected_column()?; if row.cells.is_empty() { None } else { Some(&row.cells[col.min(row.cells.len() - 1)].text) } diff --git a/yazi-shared/src/shell/mod.rs b/yazi-shared/src/shell/mod.rs index 72d015e5..c2e4abcc 100644 --- a/yazi-shared/src/shell/mod.rs +++ b/yazi-shared/src/shell/mod.rs @@ -12,13 +12,13 @@ mod unix; mod windows; #[inline] -pub fn escape_unix(s: &str) -> Cow { unix::escape_str(s) } +pub fn escape_unix(s: &str) -> Cow<'_, str> { unix::escape_str(s) } #[inline] -pub fn escape_windows(s: &str) -> Cow { windows::escape_str(s) } +pub fn escape_windows(s: &str) -> Cow<'_, str> { windows::escape_str(s) } #[inline] -pub fn escape_native(s: &str) -> Cow { +pub fn escape_native(s: &str) -> Cow<'_, str> { #[cfg(unix)] { escape_unix(s) @@ -30,7 +30,7 @@ pub fn escape_native(s: &str) -> Cow { } #[inline] -pub fn escape_os_str(s: &OsStr) -> Cow { +pub fn escape_os_str(s: &OsStr) -> Cow<'_, OsStr> { #[cfg(unix)] { unix::escape_os_str(s) diff --git a/yazi-shared/src/shell/unix.rs b/yazi-shared/src/shell/unix.rs index 621cf98d..75d1b47e 100644 --- a/yazi-shared/src/shell/unix.rs +++ b/yazi-shared/src/shell/unix.rs @@ -1,6 +1,6 @@ use std::{borrow::Cow, mem}; -pub fn escape_str(s: &str) -> Cow { +pub fn escape_str(s: &str) -> Cow<'_, str> { match escape_slice(s.as_bytes()) { Cow::Borrowed(_) => Cow::Borrowed(s), Cow::Owned(v) => String::from_utf8(v).expect("Invalid bytes returned by escape_slice()").into(), @@ -8,7 +8,7 @@ pub fn escape_str(s: &str) -> Cow { } #[cfg(unix)] -pub fn escape_os_str(s: &std::ffi::OsStr) -> Cow { +pub fn escape_os_str(s: &std::ffi::OsStr) -> Cow<'_, std::ffi::OsStr> { use std::os::unix::ffi::{OsStrExt, OsStringExt}; match escape_slice(s.as_bytes()) { @@ -17,7 +17,7 @@ pub fn escape_os_str(s: &std::ffi::OsStr) -> Cow { } } -fn escape_slice(s: &[u8]) -> Cow<[u8]> { +fn escape_slice(s: &[u8]) -> Cow<'_, [u8]> { if !s.is_empty() && s.iter().copied().all(allowed) { return Cow::Borrowed(s); } diff --git a/yazi-shared/src/shell/windows.rs b/yazi-shared/src/shell/windows.rs index 5d975431..3bf0a7c2 100644 --- a/yazi-shared/src/shell/windows.rs +++ b/yazi-shared/src/shell/windows.rs @@ -1,6 +1,6 @@ use std::{borrow::Cow, iter::repeat_n}; -pub fn escape_str(s: &str) -> Cow { +pub fn escape_str(s: &str) -> Cow<'_, str> { let bytes = s.as_bytes(); if !bytes.is_empty() && !bytes.iter().any(|&c| matches!(c, b' ' | b'"' | b'\n' | b'\t')) { return Cow::Borrowed(s); diff --git a/yazi-shared/src/translit/traits.rs b/yazi-shared/src/translit/traits.rs index 094931c0..590746f9 100644 --- a/yazi-shared/src/translit/traits.rs +++ b/yazi-shared/src/translit/traits.rs @@ -2,11 +2,11 @@ use core::str; use std::borrow::Cow; pub trait Transliterator { - fn transliterate(&self) -> Cow; + fn transliterate(&self) -> Cow<'_, str>; } impl Transliterator for &[u8] { - fn transliterate(&self) -> Cow { + fn transliterate(&self) -> Cow<'_, str> { // Fast path to skip over ASCII chars at the beginning of the string let ascii_len = self.iter().take_while(|&&c| c < 0x7f).count(); if ascii_len >= self.len() { diff --git a/yazi-term/src/tty/tty.rs b/yazi-term/src/tty/tty.rs index cbf4d8f3..51da8a6c 100644 --- a/yazi-term/src/tty/tty.rs +++ b/yazi-term/src/tty/tty.rs @@ -19,13 +19,13 @@ impl Default for Tty { } impl Tty { - pub const fn reader(&self) -> TtyReader { TtyReader(&self.stdin) } + pub const fn reader(&self) -> TtyReader<'_> { TtyReader(&self.stdin) } - pub const fn writer(&self) -> TtyWriter { TtyWriter(&self.stdout) } + pub const fn writer(&self) -> TtyWriter<'_> { TtyWriter(&self.stdout) } - pub fn lockin(&self) -> MutexGuard { self.stdin.lock() } + pub fn lockin(&self) -> MutexGuard<'_, Handle> { self.stdin.lock() } - pub fn lockout(&self) -> MutexGuard> { self.stdout.lock() } + pub fn lockout(&self) -> MutexGuard<'_, BufWriter> { self.stdout.lock() } pub fn read_until

(&self, timeout: Duration, predicate: P) -> (Vec, std::io::Result<()>) where diff --git a/yazi-widgets/src/input/input.rs b/yazi-widgets/src/input/input.rs index 7cf03da1..697e4e87 100644 --- a/yazi-widgets/src/input/input.rs +++ b/yazi-widgets/src/input/input.rs @@ -75,7 +75,7 @@ impl Input { pub fn value(&self) -> &str { &self.snap().value } #[inline] - pub fn display(&self) -> Cow { + pub fn display(&self) -> Cow<'_, str> { if self.obscure { "•".repeat(self.snap().window(self.limit).len()).into() } else {