From b692de2021e301294a4b2601ac0edd00fccf7989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=92=9C?= <113148619+donjuanplatinum@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:22:26 -0400 Subject: [PATCH] perf(linkedlist: change a mut into inmut) (#43) --- src/structure/linkedlist.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/structure/linkedlist.rs b/src/structure/linkedlist.rs index faf1d8e..78c4b0a 100644 --- a/src/structure/linkedlist.rs +++ b/src/structure/linkedlist.rs @@ -441,7 +441,7 @@ impl From<[T; N]> for LinkedList { /// ``` pub fn add_two_linkedlist(a: LinkedList, b: LinkedList) -> LinkedList { let mut result = LinkedList::new(); - let mut current = &mut result; + let current = &mut result; let (mut p1, mut p2) = (a, b); let mut sum = 0i32; while p1.front().is_some() || p2.front().is_some() || sum != 0 { @@ -468,7 +468,6 @@ pub fn add_two_linkedlist(a: LinkedList, b: LinkedList) -> LinkedList< pub fn add_two_binary_linkedlist(a: LinkedList, b: LinkedList) -> LinkedList { let mut result = LinkedList::new(); let (mut p1, mut p2) = (a, b); - let mut carry = false; // sum[0]为第一个链表的值 sum[1]为第二个链表的值 sum[2]为上次进位 let mut sum = [false; 3]; while p1.front().is_some() || p2.front().is_some() || sum[2] == true {