This commit is contained in:
sxyazi 2024-07-20 16:33:15 +08:00
parent 8fec498335
commit 095a53a3f2
No known key found for this signature in database
3 changed files with 10 additions and 10 deletions

View file

@ -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)?)?;
}

View file

@ -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)?)?;
}

View file

@ -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;