Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
shuoli84 committed Aug 8, 2024
1 parent 3409363 commit 0e4021d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/tree/entry_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub struct EntryRefDetached {

impl EntryRefDetached {
/// This is a hack to get around the borrow checker
pub fn to_ref<TR>(self, tree: TR) -> EntryRef<TR> {
pub fn into_ref<TR>(self, tree: TR) -> EntryRef<TR> {
EntryRef::<TR> {
inner_stack: self.inner_stack,
leaf_id: self.leaf_id,
Expand Down Expand Up @@ -121,7 +121,7 @@ impl<TR> EntryRef<TR> {
}
}

pub fn to_detached(self) -> EntryRefDetached {
pub fn into_detached(self) -> EntryRefDetached {
EntryRefDetached {
inner_stack: self.inner_stack,
leaf_id: self.leaf_id,
Expand Down
7 changes: 4 additions & 3 deletions src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,9 @@ where
S::Argument: SearchArgument<S::K, Query = Q>,
{
let entry_ref = self.get_ref_by_argument(query)?;
Some(Self::get_mut_by_ref(entry_ref.to_detached().to_ref(self)))
Some(Self::get_mut_by_ref(
entry_ref.into_detached().into_ref(self),
))
}

/// Get rank for argument
Expand Down Expand Up @@ -732,7 +734,7 @@ where
S::Argument: SearchArgument<S::K, Query = Q>,
{
let entry_ref = self.get_ref_by_argument(query)?;
Self::remove_by_ref(entry_ref.to_detached().to_ref(self))
Self::remove_by_ref(entry_ref.into_detached().into_ref(self))
}

/// Get the (&K, &V) pair for referece
Expand Down Expand Up @@ -967,7 +969,6 @@ mod tests {

for i in keys {
let k = i;
println!("\ndeleting {i}");

let delete_result = tree.remove(&k);
assert!(delete_result.is_some());
Expand Down
2 changes: 1 addition & 1 deletion src/tree/tree_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl<S: NodeStore> BPlusTree<S> {
S::K: Borrow<Q>,
{
let entry_ref = self.key_to_ref(k)?;
let entry_ref_mut: EntryRef<&mut Self> = entry_ref.to_detached().to_ref(self);
let entry_ref_mut: EntryRef<&mut Self> = entry_ref.into_detached().into_ref(self);
Self::remove_by_ref(entry_ref_mut)
}

Expand Down

0 comments on commit 0e4021d

Please sign in to comment.