From 8ac68bd4511ec639446832abe76301898be01526 Mon Sep 17 00:00:00 2001 From: nazeh Date: Fri, 29 Dec 2023 19:42:05 +0300 Subject: [PATCH] chore: clippy --- mast/src/operations/remove.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mast/src/operations/remove.rs b/mast/src/operations/remove.rs index 60e4ebc..25bfe52 100644 --- a/mast/src/operations/remove.rs +++ b/mast/src/operations/remove.rs @@ -5,7 +5,7 @@ use super::search::binary_search_path; use crate::node::{Branch, Node}; /// Removes the target node if it exists, and returns the new root and the removed node. -pub(crate) fn remove<'a>( +pub(crate) fn remove( nodes_table: &'_ mut Table<&'static [u8], (u64, &'static [u8])>, root: Option, key: &[u8], @@ -35,7 +35,7 @@ pub(crate) fn remove<'a>( root = Some(node); } - return (root, path.found); + (root, path.found) } fn zip( @@ -48,14 +48,13 @@ fn zip( let mut left_subtree = Vec::new(); let mut right_subtree = Vec::new(); - target - .left() - .and_then(|h| Node::open(nodes_table, h)) - .map(|n| left_subtree.push(n)); - target - .right() - .and_then(|h| Node::open(nodes_table, h)) - .map(|n| right_subtree.push(n)); + if let Some(n) = target.left().and_then(|h| Node::open(nodes_table, h)) { + left_subtree.push(n) + } + + if let Some(n) = target.right().and_then(|h| Node::open(nodes_table, h)) { + right_subtree.push(n) + } while let Some(next) = left_subtree .last()