瀏覽代碼

PreMintSecrets: fix `into_iter()` (#1244)

extracting elements from the vector using `Vec::pop` returns the
elements in the reverse order.
This commits fixes the bug by using `Vec::remove(0)`
codingpeanut157 1 周之前
父節點
當前提交
c68c5288f2
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      crates/cashu/src/nuts/nut00/mod.rs

+ 4 - 1
crates/cashu/src/nuts/nut00/mod.rs

@@ -930,7 +930,10 @@ impl Iterator for PreMintSecrets {
 
     fn next(&mut self) -> Option<Self::Item> {
         // Use the iterator of the vector
-        self.secrets.pop()
+        if self.secrets.is_empty() {
+            return None;
+        }
+        Some(self.secrets.remove(0))
     }
 }