Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
XiangpengHao committed Nov 19, 2024
1 parent 0e214c7 commit 30042a0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'a, T: Node> TypedReadGuard<'a, T> {
unsafe { &*self.node }
}

pub(crate) fn upgrade(self) -> Result<ConcreteWriteGuard<'a, T>, (Self, ArtError)> {
pub(crate) fn upgrade(self) -> Result<TypedWriteGuard<'a, T>, (Self, ArtError)> {
let new_version = self.version + 0b10;
match self
.as_ref()
Expand All @@ -28,20 +28,20 @@ impl<'a, T: Node> TypedReadGuard<'a, T> {
Ordering::Release,
Ordering::Relaxed,
) {
Ok(_) => Ok(ConcreteWriteGuard {
Ok(_) => Ok(TypedWriteGuard {
// SAFETY: this is seems to be unsound, but we (1) acquired write lock, (2) has the right memory ordering.
node: unsafe { &mut *(self.node as *const T as *mut T) },
node: unsafe { &mut *(self.node as *mut T) },
}),
Err(_v) => Err((self, ArtError::VersionNotMatch)),
}
}
}

pub(crate) struct ConcreteWriteGuard<'a, T: Node> {
pub(crate) struct TypedWriteGuard<'a, T: Node> {
node: &'a mut T,
}

impl<'a, T: Node> ConcreteWriteGuard<'a, T> {
impl<T: Node> TypedWriteGuard<'_, T> {
pub(crate) fn as_ref(&self) -> &T {
self.node
}
Expand All @@ -58,7 +58,7 @@ impl<'a, T: Node> ConcreteWriteGuard<'a, T> {
}
}

impl<'a, T: Node> Drop for ConcreteWriteGuard<'a, T> {
impl<T: Node> Drop for TypedWriteGuard<'_, T> {
fn drop(&mut self) {
self.node
.base()
Expand Down Expand Up @@ -105,7 +105,7 @@ impl<'a> ReadGuard<'a> {

TypedReadGuard {
version: self.version,
node: unsafe { &*(self.node as *const BaseNode as *const T) },
node: unsafe { &*(self.node as *const T) },
_pt_node: PhantomData,
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ pub(crate) struct WriteGuard<'a> {
node: &'a mut BaseNode,
}

impl<'a> WriteGuard<'a> {
impl WriteGuard<'_> {
pub(crate) fn as_ref(&self) -> &BaseNode {
self.node
}
Expand All @@ -160,7 +160,7 @@ impl<'a> WriteGuard<'a> {
}
}

impl<'a> Drop for WriteGuard<'a> {
impl Drop for WriteGuard<'_> {
fn drop(&mut self) {
self.node
.type_version_lock_obsolete
Expand Down
2 changes: 1 addition & 1 deletion src/node_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub(crate) struct Node16Iter<'a> {
end_pos: usize,
}

impl<'a> Iterator for Node16Iter<'a> {
impl Iterator for Node16Iter<'_> {
type Item = (u8, NodePtr);

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion src/node_256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub(crate) struct Node256Iter<'a> {
node: &'a Node256,
}

impl<'a> Iterator for Node256Iter<'a> {
impl Iterator for Node256Iter<'_> {
type Item = (u8, NodePtr);

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion src/node_48.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub(crate) struct Node48Iter<'a> {
node: &'a Node48,
}

impl<'a> Iterator for Node48Iter<'a> {
impl Iterator for Node48Iter<'_> {
type Item = (u8, NodePtr);

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion src/node_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<N: Node> AllocatedNode<N> {
pub(crate) fn into_note_ptr(self) -> NodePtr {
let ptr = self.ptr;
std::mem::forget(self);
unsafe { NodePtr::from_node_new(std::mem::transmute(ptr)) }
unsafe { NodePtr::from_node_new(std::mem::transmute::<NonNull<N>, NonNull<BaseNode>>(ptr)) }
}
}

Expand Down

0 comments on commit 30042a0

Please sign in to comment.