Prevent usize overflow when no records found

This commit is contained in:
Tobie Morgan Hitchcock 2022-03-21 13:48:59 +00:00
parent 5ae5046987
commit 0b3f4c5765
3 changed files with 36 additions and 12 deletions

View file

@ -147,12 +147,16 @@ impl Table {
};
if !res.is_empty() {
// Get total results
let n = res.len() - 1;
let n = res.len();
// Exit when settled
if n == 0 {
break;
}
// Loop over results
for (i, (k, v)) in res.into_iter().enumerate() {
if ctx.is_ok() {
// Ready the next
if i == n {
if n == i + 1 {
nxt = Some(k.clone());
}
// Parse the key-value

View file

@ -144,12 +144,16 @@ impl Table {
};
if !res.is_empty() {
// Get total results
let n = res.len() - 1;
let n = res.len();
// Exit when settled
if n == 0 {
break;
}
// Loop over results
for (i, (k, v)) in res.into_iter().enumerate() {
if ctx.is_ok() {
// Ready the next
if i == n {
if n == i + 1 {
nxt = Some(k.clone());
}
// Parse the key-value

View file

@ -191,11 +191,15 @@ impl Transaction {
}
};
// Get total results
let n = res.len() - 1;
let n = res.len();
// Exit when settled
if n == 0 {
break;
}
// Loop over results
for (i, (k, v)) in res.into_iter().enumerate() {
// Ready the next
if i == n {
if n == i + 1 {
nxt = Some(k.clone());
}
// Delete
@ -234,11 +238,15 @@ impl Transaction {
}
};
// Get total results
let n = res.len() - 1;
let n = res.len();
// Exit when settled
if n == 0 {
break;
}
// Loop over results
for (i, (k, _)) in res.into_iter().enumerate() {
// Ready the next
if i == n {
if n == i + 1 {
nxt = Some(k.clone());
}
// Delete
@ -278,11 +286,15 @@ impl Transaction {
}
};
// Get total results
let n = res.len() - 1;
let n = res.len();
// Exit when settled
if n == 0 {
break;
}
// Loop over results
for (i, (k, v)) in res.into_iter().enumerate() {
// Ready the next
if i == n {
if n == i + 1 {
nxt = Some(k.clone());
}
// Delete
@ -321,11 +333,15 @@ impl Transaction {
}
};
// Get total results
let n = res.len() - 1;
let n = res.len();
// Exit when settled
if n == 0 {
break;
}
// Loop over results
for (i, (k, _)) in res.into_iter().enumerate() {
// Ready the next
if i == n {
if n == i + 1 {
nxt = Some(k.clone());
}
// Delete