diff --git a/yazi-actor/src/context.rs b/yazi-actor/src/context.rs index 876826ac..9e5446ce 100644 --- a/yazi-actor/src/context.rs +++ b/yazi-actor/src/context.rs @@ -40,7 +40,7 @@ impl<'a> Ctx<'a> { } #[inline] - pub fn renew<'b>(cx: &'a mut Ctx<'b>) -> Ctx<'a> { + pub fn renew<'b>(cx: &'a mut Ctx<'b>) -> Self { let tab = cx.core.mgr.tabs.cursor; Self { core: cx.core, tab, level: cx.level, source: cx.source } } diff --git a/yazi-adapter/src/mux.rs b/yazi-adapter/src/mux.rs index 167a2b5f..b102acd6 100644 --- a/yazi-adapter/src/mux.rs +++ b/yazi-adapter/src/mux.rs @@ -50,7 +50,7 @@ impl Mux { pub fn tmux_drain() -> Result<()> { if TMUX.get() { - crossterm::execute!(TTY.writer(), crossterm::style::Print(Mux::csi("\x1b[5n")))?; + crossterm::execute!(TTY.writer(), crossterm::style::Print(Self::csi("\x1b[5n")))?; _ = Emulator::read_until_dsr(); } Ok(()) diff --git a/yazi-binding/src/elements/border.rs b/yazi-binding/src/elements/border.rs index 0767fe49..ab9866f7 100644 --- a/yazi-binding/src/elements/border.rs +++ b/yazi-binding/src/elements/border.rs @@ -26,7 +26,7 @@ pub struct Border { impl Border { pub fn compose(lua: &Lua) -> mlua::Result { let new = lua.create_function(|_, (_, edge): (Table, Edge)| { - Ok(Border { edge, r#type: ratatui::widgets::BorderType::Rounded, ..Default::default() }) + Ok(Self { edge, r#type: ratatui::widgets::BorderType::Rounded, ..Default::default() }) })?; let border = lua.create_table_from([ diff --git a/yazi-binding/src/elements/clear.rs b/yazi-binding/src/elements/clear.rs index 0e41c2b1..1110f0ff 100644 --- a/yazi-binding/src/elements/clear.rs +++ b/yazi-binding/src/elements/clear.rs @@ -14,7 +14,7 @@ pub struct Clear { impl Clear { pub fn compose(lua: &Lua) -> mlua::Result { - let new = lua.create_function(|_, (_, area): (Table, Area)| Ok(Clear { area }))?; + let new = lua.create_function(|_, (_, area): (Table, Area)| Ok(Self { area }))?; let clear = lua.create_table()?; clear.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; diff --git a/yazi-binding/src/elements/gauge.rs b/yazi-binding/src/elements/gauge.rs index 3a3bd59e..2d1d1487 100644 --- a/yazi-binding/src/elements/gauge.rs +++ b/yazi-binding/src/elements/gauge.rs @@ -16,7 +16,7 @@ pub struct Gauge { impl Gauge { pub fn compose(lua: &Lua) -> mlua::Result { - let new = lua.create_function(|_, _: Table| Ok(Gauge::default()))?; + let new = lua.create_function(|_, _: Table| Ok(Self::default()))?; let gauge = lua.create_table()?; gauge.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; diff --git a/yazi-binding/src/elements/line.rs b/yazi-binding/src/elements/line.rs index 042c23a2..69df7adb 100644 --- a/yazi-binding/src/elements/line.rs +++ b/yazi-binding/src/elements/line.rs @@ -29,20 +29,20 @@ impl DerefMut for Line { impl Line { pub fn compose(lua: &Lua) -> mlua::Result { - let new = lua.create_function(|_, (_, value): (Table, Value)| Line::try_from(value))?; + let new = lua.create_function(|_, (_, value): (Table, Value)| Self::try_from(value))?; let parse = lua.create_function(|_, code: mlua::String| { let code = code.as_bytes(); let Some(line) = code.split_inclusive(|&b| b == b'\n').next() else { - return Ok(Line::default()); + return Ok(Self::default()); }; let mut lines = line.into_text().into_lua_err()?.lines; if lines.is_empty() { - return Ok(Line::default()); + return Ok(Self::default()); } - Ok(Line { inner: mem::take(&mut lines[0]), ..Default::default() }) + Ok(Self { inner: mem::take(&mut lines[0]), ..Default::default() }) })?; let line = lua.create_table_from([("parse", parse)])?; @@ -90,7 +90,7 @@ impl TryFrom for Line { Value::UserData(ud) => { if let Ok(Span(span)) = ud.take() { spans.push(span); - } else if let Ok(Line { inner: mut line, .. }) = ud.take() { + } else if let Ok(Self { inner: mut line, .. }) = ud.take() { line.spans.iter_mut().for_each(|s| s.style = line.style.patch(s.style)); spans.extend(line.spans); } else { diff --git a/yazi-binding/src/elements/rect.rs b/yazi-binding/src/elements/rect.rs index 13685949..c1f8262d 100644 --- a/yazi-binding/src/elements/rect.rs +++ b/yazi-binding/src/elements/rect.rs @@ -83,6 +83,6 @@ impl UserData for Rect { fn add_methods>(methods: &mut M) { methods.add_method("pad", |_, me, pad: Pad| Ok(me.pad(pad))); - methods.add_method("contains", |_, me, Rect(rect)| Ok(me.contains(rect.into()))); + methods.add_method("contains", |_, me, Self(rect)| Ok(me.contains(rect.into()))); } } diff --git a/yazi-binding/src/elements/span.rs b/yazi-binding/src/elements/span.rs index 39e85b45..8858a1fb 100644 --- a/yazi-binding/src/elements/span.rs +++ b/yazi-binding/src/elements/span.rs @@ -19,7 +19,7 @@ impl DerefMut for Span { impl Span { pub fn compose(lua: &Lua) -> mlua::Result { - let new = lua.create_function(|_, (_, value): (Table, Value)| Span::try_from(value))?; + let new = lua.create_function(|_, (_, value): (Table, Value)| Self::try_from(value))?; let span = lua.create_table()?; span.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; @@ -65,7 +65,7 @@ impl TryFrom for Span { Ok(Self(match value { Value::String(s) => s.to_string_lossy().into(), Value::UserData(ud) => { - if let Ok(Span(span)) = ud.take() { + if let Ok(Self(span)) = ud.take() { span } else { Err(EXPECTED.into_lua_err())? @@ -81,7 +81,7 @@ impl UserData for Span { crate::impl_style_method!(methods, 0.style); crate::impl_style_shorthands!(methods, 0.style); - methods.add_method("visible", |_, Span(me), ()| { + methods.add_method("visible", |_, Self(me), ()| { Ok(me.content.chars().any(|c| c.width().unwrap_or(0) > 0)) }); methods.add_function_mut("truncate", |_, (ud, t): (AnyUserData, Table)| { diff --git a/yazi-binding/src/elements/text.rs b/yazi-binding/src/elements/text.rs index 20f6a275..69147602 100644 --- a/yazi-binding/src/elements/text.rs +++ b/yazi-binding/src/elements/text.rs @@ -21,10 +21,10 @@ pub struct Text { impl Text { pub fn compose(lua: &Lua) -> mlua::Result { - let new = lua.create_function(|_, (_, value): (Table, Value)| Text::try_from(value))?; + let new = lua.create_function(|_, (_, value): (Table, Value)| Self::try_from(value))?; let parse = lua.create_function(|_, code: mlua::String| { - Ok(Text { inner: code.as_bytes().into_text().into_lua_err()?, ..Default::default() }) + Ok(Self { inner: code.as_bytes().into_text().into_lua_err()?, ..Default::default() }) })?; let text = lua.create_table_from([("parse", parse)])?; @@ -51,7 +51,7 @@ impl TryFrom for Text { Value::UserData(ud) => match ud.type_id() { Some(t) if t == TypeId::of::() => ud.take::()?.inner.into(), Some(t) if t == TypeId::of::() => ud.take::()?.0.into(), - Some(t) if t == TypeId::of::() => return ud.take(), + Some(t) if t == TypeId::of::() => return ud.take(), Some(t) if t == TypeId::of::() => ud.take::()?.into_string().into(), _ => Err(EXPECTED.into_lua_err())?, }, diff --git a/yazi-binding/src/error.rs b/yazi-binding/src/error.rs index 99c8f3e0..575f36bf 100644 --- a/yazi-binding/src/error.rs +++ b/yazi-binding/src/error.rs @@ -14,7 +14,7 @@ pub enum Error { impl Error { pub fn install(lua: &Lua) -> mlua::Result<()> { - let new = lua.create_function(|_, msg: String| Ok(Error::custom(msg)))?; + let new = lua.create_function(|_, msg: String| Ok(Self::custom(msg)))?; lua.globals().raw_set("Error", lua.create_table_from([("custom", new)])?) } @@ -23,10 +23,10 @@ impl Error { pub fn into_string(self) -> SStr { match self { - Error::Io(e) => Cow::Owned(e.to_string()), - Error::IoKind(e) => Cow::Owned(e.to_string()), - Error::Serde(e) => Cow::Owned(e.to_string()), - Error::Custom(s) => s, + Self::Io(e) => Cow::Owned(e.to_string()), + Self::IoKind(e) => Cow::Owned(e.to_string()), + Self::Serde(e) => Cow::Owned(e.to_string()), + Self::Custom(s) => s, } } } @@ -34,10 +34,10 @@ impl Error { impl Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Error::Io(e) => write!(f, "{e}"), - Error::IoKind(e) => write!(f, "{e}"), - Error::Serde(e) => write!(f, "{e}"), - Error::Custom(s) => write!(f, "{s}"), + Self::Io(e) => write!(f, "{e}"), + Self::IoKind(e) => write!(f, "{e}"), + Self::Serde(e) => write!(f, "{e}"), + Self::Custom(s) => write!(f, "{s}"), } } } @@ -55,7 +55,7 @@ impl UserData for Error { fn add_fields>(fields: &mut F) { fields.add_field_method_get("code", |_, me| { Ok(match me { - Error::Io(e) => e.raw_os_error(), + Self::Io(e) => e.raw_os_error(), _ => None, }) }); @@ -64,8 +64,8 @@ impl UserData for Error { fn add_methods>(methods: &mut M) { methods.add_meta_method(MetaMethod::ToString, |lua, me, ()| { Ok(match me { - Error::Io(_) | Error::IoKind(_) | Error::Serde(_) => lua.create_string(me.to_string()), - Error::Custom(s) => lua.create_string(s.as_ref()), + Self::Io(_) | Self::IoKind(_) | Self::Serde(_) => lua.create_string(me.to_string()), + Self::Custom(s) => lua.create_string(s.as_ref()), }) }); methods.add_meta_function(MetaMethod::Concat, |lua, (lhs, rhs): (Value, Value)| { diff --git a/yazi-binding/src/url.rs b/yazi-binding/src/url.rs index 4af92936..7e8182eb 100644 --- a/yazi-binding/src/url.rs +++ b/yazi-binding/src/url.rs @@ -44,7 +44,7 @@ impl<'a> From<&'a Url> for UrlCow<'a> { } impl From for yazi_shared::url::UrlBufCov { - fn from(value: Url) -> Self { UrlBufCov(value.inner) } + fn from(value: Url) -> Self { Self(value.inner) } } impl TryFrom<&[u8]> for Url { diff --git a/yazi-config/src/style.rs b/yazi-config/src/style.rs index 1476b733..46602ba4 100644 --- a/yazi-config/src/style.rs +++ b/yazi-config/src/style.rs @@ -31,7 +31,7 @@ pub struct Style { impl From