mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
8fec498335
commit
095a53a3f2
3 changed files with 10 additions and 10 deletions
|
|
@ -29,10 +29,10 @@ impl IntoLua<'_> for BodyDelete<'static> {
|
|||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value<'_>> {
|
||||
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)?)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ impl IntoLua<'_> for BodyTrash<'static> {
|
|||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value<'_>> {
|
||||
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)?)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@ pub struct RoCell<T>(UnsafeCell<Option<T>>);
|
|||
|
||||
unsafe impl<T> Sync for RoCell<T> {}
|
||||
|
||||
impl<T> Default for RoCell<T> {
|
||||
fn default() -> Self { Self::new() }
|
||||
}
|
||||
|
||||
impl<T> RoCell<T> {
|
||||
#[inline]
|
||||
pub const fn new() -> Self { Self(UnsafeCell::new(None)) }
|
||||
|
|
@ -47,6 +43,10 @@ impl<T> RoCell<T> {
|
|||
fn initialized(&self) -> bool { unsafe { (*self.0.get()).is_some() } }
|
||||
}
|
||||
|
||||
impl<T> Default for RoCell<T> {
|
||||
fn default() -> Self { Self::new() }
|
||||
}
|
||||
|
||||
impl<T> Deref for RoCell<T> {
|
||||
type Target = T;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue