fix(pagination): prevent usize underflow when total_pages is zero
When there are no items, total_pages is 0 and `total_pages - 1` causes a subtract-with-overflow panic on usize. Guard the subtraction with a `total_pages > 0` check.
This commit is contained in:
@@ -93,7 +93,7 @@ impl<T> PaginatedResponseDto<T> {
|
||||
page_size,
|
||||
total_items,
|
||||
total_pages,
|
||||
has_next: page < total_pages - 1,
|
||||
has_next: total_pages > 0 && page < total_pages - 1,
|
||||
has_prev: page > 0,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user