mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
Derive PartialEq instead of implementing manually
This commit is contained in:
+1
-7
@@ -20,7 +20,7 @@ use {
|
||||
};
|
||||
|
||||
/// Handle to an internal Lua function.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Function(pub(crate) ValueRef);
|
||||
|
||||
/// Contains information about a function.
|
||||
@@ -509,12 +509,6 @@ impl Function {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Function {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0 == other.0
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct WrappedFunction(pub(crate) Callback);
|
||||
|
||||
#[cfg(feature = "async")]
|
||||
|
||||
+2
-8
@@ -23,7 +23,7 @@ use crate::value::{FromLua, FromLuaMulti, IntoLua, IntoLuaMulti, Nil, Value};
|
||||
use futures_util::future::{self, Either, Future};
|
||||
|
||||
/// Handle to an internal Lua table.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct Table(pub(crate) ValueRef);
|
||||
|
||||
impl Table {
|
||||
@@ -806,13 +806,7 @@ impl fmt::Debug for Table {
|
||||
if fmt.alternate() {
|
||||
return self.fmt_pretty(fmt, 0, &mut HashSet::new());
|
||||
}
|
||||
fmt.write_fmt(format_args!("Table({:?})", self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Table {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0 == other.0
|
||||
fmt.debug_tuple("Table").field(&self.0).finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -1,3 +1,4 @@
|
||||
use std::fmt;
|
||||
use std::os::raw::{c_int, c_void};
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
@@ -42,7 +43,7 @@ pub enum ThreadStatus {
|
||||
}
|
||||
|
||||
/// Handle to an internal Lua thread (coroutine).
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub struct Thread(pub(crate) ValueRef, pub(crate) *mut ffi::lua_State);
|
||||
|
||||
#[cfg(feature = "send")]
|
||||
@@ -366,6 +367,12 @@ impl Thread {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Thread {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_tuple("Thread").field(&self.0).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Thread {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0 == other.0
|
||||
|
||||
+2
-8
@@ -128,7 +128,7 @@ pub enum MetaMethod {
|
||||
///
|
||||
/// Executed when a variable, that marked as to-be-closed, goes out of scope.
|
||||
///
|
||||
/// More information about to-be-closed variabled can be found in the Lua 5.4
|
||||
/// More information about to-be-closed variables can be found in the Lua 5.4
|
||||
/// [documentation][lua_doc].
|
||||
///
|
||||
/// Requires `feature = "lua54"`
|
||||
@@ -642,7 +642,7 @@ pub trait UserData: Sized {
|
||||
/// [`UserData`]: crate::UserData
|
||||
/// [`is`]: crate::AnyUserData::is
|
||||
/// [`borrow`]: crate::AnyUserData::borrow
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct AnyUserData(pub(crate) ValueRef);
|
||||
|
||||
impl AnyUserData {
|
||||
@@ -1009,12 +1009,6 @@ impl AnyUserData {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for AnyUserData {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0 == other.0
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<AnyUserData> for AnyUserData {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &Self {
|
||||
|
||||
Reference in New Issue
Block a user