Skip to content

Commit 4ac87c7

Browse files
committed
Derive PartialEq instead of implementing manually
1 parent 04d8106 commit 4ac87c7

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

src/function.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use {
2020
};
2121

2222
/// Handle to an internal Lua function.
23-
#[derive(Clone, Debug)]
23+
#[derive(Clone, Debug, PartialEq)]
2424
pub struct Function(pub(crate) ValueRef);
2525

2626
/// Contains information about a function.
@@ -509,12 +509,6 @@ impl Function {
509509
}
510510
}
511511

512-
impl PartialEq for Function {
513-
fn eq(&self, other: &Self) -> bool {
514-
self.0 == other.0
515-
}
516-
}
517-
518512
pub(crate) struct WrappedFunction(pub(crate) Callback);
519513

520514
#[cfg(feature = "async")]

src/table.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::value::{FromLua, FromLuaMulti, IntoLua, IntoLuaMulti, Nil, Value};
2323
use futures_util::future::{self, Either, Future};
2424

2525
/// Handle to an internal Lua table.
26-
#[derive(Clone)]
26+
#[derive(Clone, PartialEq)]
2727
pub struct Table(pub(crate) ValueRef);
2828

2929
impl Table {
@@ -806,13 +806,7 @@ impl fmt::Debug for Table {
806806
if fmt.alternate() {
807807
return self.fmt_pretty(fmt, 0, &mut HashSet::new());
808808
}
809-
fmt.write_fmt(format_args!("Table({:?})", self.0))
810-
}
811-
}
812-
813-
impl PartialEq for Table {
814-
fn eq(&self, other: &Self) -> bool {
815-
self.0 == other.0
809+
fmt.debug_tuple("Table").field(&self.0).finish()
816810
}
817811
}
818812

src/thread.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::fmt;
12
use std::os::raw::{c_int, c_void};
23

34
use crate::error::{Error, Result};
@@ -42,7 +43,7 @@ pub enum ThreadStatus {
4243
}
4344

4445
/// Handle to an internal Lua thread (coroutine).
45-
#[derive(Clone, Debug)]
46+
#[derive(Clone)]
4647
pub struct Thread(pub(crate) ValueRef, pub(crate) *mut ffi::lua_State);
4748

4849
#[cfg(feature = "send")]
@@ -366,6 +367,12 @@ impl Thread {
366367
}
367368
}
368369

370+
impl fmt::Debug for Thread {
371+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
372+
fmt.debug_tuple("Thread").field(&self.0).finish()
373+
}
374+
}
375+
369376
impl PartialEq for Thread {
370377
fn eq(&self, other: &Self) -> bool {
371378
self.0 == other.0

src/userdata.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub enum MetaMethod {
128128
///
129129
/// Executed when a variable, that marked as to-be-closed, goes out of scope.
130130
///
131-
/// More information about to-be-closed variabled can be found in the Lua 5.4
131+
/// More information about to-be-closed variables can be found in the Lua 5.4
132132
/// [documentation][lua_doc].
133133
///
134134
/// Requires `feature = "lua54"`
@@ -642,7 +642,7 @@ pub trait UserData: Sized {
642642
/// [`UserData`]: crate::UserData
643643
/// [`is`]: crate::AnyUserData::is
644644
/// [`borrow`]: crate::AnyUserData::borrow
645-
#[derive(Clone, Debug)]
645+
#[derive(Clone, Debug, PartialEq)]
646646
pub struct AnyUserData(pub(crate) ValueRef);
647647

648648
impl AnyUserData {
@@ -1009,12 +1009,6 @@ impl AnyUserData {
10091009
}
10101010
}
10111011

1012-
impl PartialEq for AnyUserData {
1013-
fn eq(&self, other: &Self) -> bool {
1014-
self.0 == other.0
1015-
}
1016-
}
1017-
10181012
impl AsRef<AnyUserData> for AnyUserData {
10191013
#[inline]
10201014
fn as_ref(&self) -> &Self {

0 commit comments

Comments
 (0)