Replaced direct cast from usize to i32 with try_into() to ensure safe conversion and prevent overflow, adding explicit error handling if usize exceeds the i32 range.
Replaced direct cast from i64 to usize with usize::try_from() to safely handle conversion and avoid truncation on 32-bit systems.
Added error handling for the conversion of pagination.total to usize, ensuring the value fits within the valid range for usize.
Updated loop conditions to use the results of try_into() and try_from() conversions to continue iterating only if the casts are successful.
usize
toi32
withtry_into()
to ensure safe conversion and prevent overflow, adding explicit error handling ifusize
exceeds thei32
range.i64
tousize
withusize::try_from()
to safely handle conversion and avoid truncation on 32-bit systems.pagination.total
tousize
, ensuring the value fits within the valid range forusize
.try_into()
andtry_from()
conversions to continue iterating only if the casts are successful.