diff --git a/yazi-dds/src/body/delete.rs b/yazi-dds/src/body/delete.rs index db82125b..41ae524d 100644 --- a/yazi-dds/src/body/delete.rs +++ b/yazi-dds/src/body/delete.rs @@ -29,10 +29,10 @@ impl IntoLua<'_> for BodyDelete<'static> { fn into_lua(self, lua: &Lua) -> mlua::Result> { let urls = lua.create_table_with_capacity(self.urls.len(), 0)?; + // In most cases, `self.urls` will be `Cow::Owned`, so + // `.into_owned().into_iter()` can avoid any cloning, whereas + // `.iter().cloned()` will clone each element. #[allow(clippy::unnecessary_to_owned)] - // In most cases, self.urls will be Cow::Owned, so - // .into_owned().into_iter() can avoid any cloning, whereas - // .iter().cloned() will clone each element. for (i, url) in self.urls.into_owned().into_iter().enumerate() { urls.raw_set(i + 1, lua.create_any_userdata(url)?)?; } diff --git a/yazi-dds/src/body/trash.rs b/yazi-dds/src/body/trash.rs index fbb779ba..cac54fd9 100644 --- a/yazi-dds/src/body/trash.rs +++ b/yazi-dds/src/body/trash.rs @@ -29,10 +29,10 @@ impl IntoLua<'_> for BodyTrash<'static> { fn into_lua(self, lua: &Lua) -> mlua::Result> { let urls = lua.create_table_with_capacity(self.urls.len(), 0)?; + // In most cases, `self.urls` will be `Cow::Owned`, so + // `.into_owned().into_iter()` can avoid any cloning, whereas + // `.iter().cloned()` will clone each element. #[allow(clippy::unnecessary_to_owned)] - // In most cases, self.urls will be Cow::Owned, so - // .into_owned().into_iter() can avoid any cloning, whereas - // .iter().cloned() will clone each element. for (i, url) in self.urls.into_owned().into_iter().enumerate() { urls.raw_set(i + 1, lua.create_any_userdata(url)?)?; } diff --git a/yazi-shared/src/ro_cell.rs b/yazi-shared/src/ro_cell.rs index 091f0c37..5d7c95c8 100644 --- a/yazi-shared/src/ro_cell.rs +++ b/yazi-shared/src/ro_cell.rs @@ -7,10 +7,6 @@ pub struct RoCell(UnsafeCell>); unsafe impl Sync for RoCell {} -impl Default for RoCell { - fn default() -> Self { Self::new() } -} - impl RoCell { #[inline] pub const fn new() -> Self { Self(UnsafeCell::new(None)) } @@ -47,6 +43,10 @@ impl RoCell { fn initialized(&self) -> bool { unsafe { (*self.0.get()).is_some() } } } +impl Default for RoCell { + fn default() -> Self { Self::new() } +} + impl Deref for RoCell { type Target = T;