We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 37ebc2c commit 5a8bf5aCopy full SHA for 5a8bf5a
src/types/quota.rs
@@ -48,7 +48,11 @@ impl From<QuotaResourceRef<'_>> for QuotaResource {
48
impl QuotaResource {
49
/// Returns the usage percentage of a QuotaResource.
50
pub fn get_usage_percentage(&self) -> u64 {
51
- self.usage.saturating_mul(100) / self.limit
+ self.usage
52
+ .saturating_mul(100)
53
+ .checked_div(self.limit)
54
+ // Assume that if `limit` is 0, this means that storage is unlimited:
55
+ .unwrap_or(0)
56
}
57
58
0 commit comments