mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 14:51:03 +00:00
refactor: satisfy mismatched-lifetime-syntaxes lint (#2881)
This commit is contained in:
parent
52d37fa25d
commit
a076ff8c82
14 changed files with 33 additions and 31 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<str> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ macro_rules! impl_pub_body {
|
|||
($name:ident) => {
|
||||
impl $name {
|
||||
#[allow(dead_code)]
|
||||
pub(super) fn body(&self) -> Result<Cow<str>> {
|
||||
pub(super) fn body(&self) -> Result<Cow<'_, str>> {
|
||||
Ok(if let Some(json) = &self.json {
|
||||
json.into()
|
||||
} else if let Some(str) = &self.str {
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ impl Chord {
|
|||
.into_owned()
|
||||
}
|
||||
|
||||
pub fn desc(&self) -> Option<Cow<str>> {
|
||||
pub fn desc(&self) -> Option<Cow<'_, str>> {
|
||||
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<str> { 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();
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ impl From<&str> for Separator {
|
|||
}
|
||||
|
||||
impl Separator {
|
||||
fn transform<T: AsRef<Path> + ?Sized>(self, p: &T) -> Cow<OsStr> {
|
||||
fn transform<T: AsRef<Path> + ?Sized>(self, p: &T) -> Cow<'_, OsStr> {
|
||||
#[cfg(windows)]
|
||||
if self == Self::Unix {
|
||||
return match yazi_fs::backslash_to_slash(p.as_ref()) {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ impl Term {
|
|||
std::process::exit(f());
|
||||
}
|
||||
|
||||
pub(super) fn draw(&mut self, f: impl FnOnce(&mut Frame)) -> io::Result<CompletedFrame> {
|
||||
pub(super) fn draw(&mut self, f: impl FnOnce(&mut Frame)) -> io::Result<CompletedFrame<'_>> {
|
||||
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<CompletedFrame> {
|
||||
pub(super) fn draw_partial(
|
||||
&mut self,
|
||||
f: impl FnOnce(&mut Frame),
|
||||
) -> io::Result<CompletedFrame<'_>> {
|
||||
self.inner.draw(|frame| {
|
||||
let buffer = frame.buffer_mut();
|
||||
for y in self.last_area.top()..self.last_area.bottom() {
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ mod unix;
|
|||
mod windows;
|
||||
|
||||
#[inline]
|
||||
pub fn escape_unix(s: &str) -> Cow<str> { unix::escape_str(s) }
|
||||
pub fn escape_unix(s: &str) -> Cow<'_, str> { unix::escape_str(s) }
|
||||
|
||||
#[inline]
|
||||
pub fn escape_windows(s: &str) -> Cow<str> { windows::escape_str(s) }
|
||||
pub fn escape_windows(s: &str) -> Cow<'_, str> { windows::escape_str(s) }
|
||||
|
||||
#[inline]
|
||||
pub fn escape_native(s: &str) -> Cow<str> {
|
||||
pub fn escape_native(s: &str) -> Cow<'_, str> {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
escape_unix(s)
|
||||
|
|
@ -30,7 +30,7 @@ pub fn escape_native(s: &str) -> Cow<str> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn escape_os_str(s: &OsStr) -> Cow<OsStr> {
|
||||
pub fn escape_os_str(s: &OsStr) -> Cow<'_, OsStr> {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
unix::escape_os_str(s)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::{borrow::Cow, mem};
|
||||
|
||||
pub fn escape_str(s: &str) -> Cow<str> {
|
||||
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<str> {
|
|||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub fn escape_os_str(s: &std::ffi::OsStr) -> Cow<std::ffi::OsStr> {
|
||||
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<std::ffi::OsStr> {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::{borrow::Cow, iter::repeat_n};
|
||||
|
||||
pub fn escape_str(s: &str) -> Cow<str> {
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ use core::str;
|
|||
use std::borrow::Cow;
|
||||
|
||||
pub trait Transliterator {
|
||||
fn transliterate(&self) -> Cow<str>;
|
||||
fn transliterate(&self) -> Cow<'_, str>;
|
||||
}
|
||||
|
||||
impl Transliterator for &[u8] {
|
||||
fn transliterate(&self) -> Cow<str> {
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -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<Handle> { self.stdin.lock() }
|
||||
pub fn lockin(&self) -> MutexGuard<'_, Handle> { self.stdin.lock() }
|
||||
|
||||
pub fn lockout(&self) -> MutexGuard<BufWriter<Handle>> { self.stdout.lock() }
|
||||
pub fn lockout(&self) -> MutexGuard<'_, BufWriter<Handle>> { self.stdout.lock() }
|
||||
|
||||
pub fn read_until<P>(&self, timeout: Duration, predicate: P) -> (Vec<u8>, std::io::Result<()>)
|
||||
where
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ impl Input {
|
|||
pub fn value(&self) -> &str { &self.snap().value }
|
||||
|
||||
#[inline]
|
||||
pub fn display(&self) -> Cow<str> {
|
||||
pub fn display(&self) -> Cow<'_, str> {
|
||||
if self.obscure {
|
||||
"•".repeat(self.snap().window(self.limit).len()).into()
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue