Skip to content

Commit 705ef65

Browse files
committed
chore: fix clippy warning in rust 1.87.0
The code is shorter and probably clearer in its intent now. The error was: ``` warning: use `std::ptr::eq` when comparing raw pointers --> rusqlite_migration/src/lib.rs:108:35 | 108 | (Some(a), Some(b)) => addr_of!(*a) as usize == addr_of!(*b) as usize, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(addr_of!(*a), addr_of!(*b))` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq = note: `#[warn(clippy::ptr_eq)]` on by default warning: use `std::ptr::eq` when comparing raw pointers --> rusqlite_migration/src/lib.rs:114:35 | 114 | (Some(a), Some(b)) => addr_of!(*a) as usize == addr_of!(*b) as usize, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(addr_of!(*a), addr_of!(*b))` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq warning: `rusqlite_migration` (lib) generated 2 warnings (run `cargo clippy --fix --lib -p rusqlite_migration` to apply 2 suggestions) ```
1 parent dd56ade commit 705ef65

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

rusqlite_migration/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,17 @@ pub struct M<'u> {
103103

104104
impl PartialEq for M<'_> {
105105
fn eq(&self, other: &Self) -> bool {
106+
use std::ptr;
107+
106108
let equal_up_hooks = match (self.up_hook.as_ref(), other.up_hook.as_ref()) {
107109
(None, None) => true,
108-
(Some(a), Some(b)) => addr_of!(*a) as usize == addr_of!(*b) as usize,
110+
(Some(a), Some(b)) => ptr::eq(addr_of!(*a), addr_of!(*b)),
109111
_ => false,
110112
};
111113

112114
let equal_down_hooks = match (self.down_hook.as_ref(), other.down_hook.as_ref()) {
113115
(None, None) => true,
114-
(Some(a), Some(b)) => addr_of!(*a) as usize == addr_of!(*b) as usize,
116+
(Some(a), Some(b)) => ptr::eq(addr_of!(*a), addr_of!(*b)),
115117
_ => false,
116118
};
117119

0 commit comments

Comments
 (0)