From 327d369188a134909284b43692bdfac25f7751bd Mon Sep 17 00:00:00 2001 From: Integral Date: Sat, 11 Jan 2025 04:06:38 +0800 Subject: [PATCH] refactor: replace static with const for global constants (#5260) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel GarcĂ­a --- src/crypto.rs | 2 +- src/db/models/organization.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crypto.rs b/src/crypto.rs index eff1785f..a987b0fe 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -6,7 +6,7 @@ use std::num::NonZeroU32; use data_encoding::{Encoding, HEXLOWER}; use ring::{digest, hmac, pbkdf2}; -static DIGEST_ALG: pbkdf2::Algorithm = pbkdf2::PBKDF2_HMAC_SHA256; +const DIGEST_ALG: pbkdf2::Algorithm = pbkdf2::PBKDF2_HMAC_SHA256; const OUTPUT_LEN: usize = digest::SHA256_OUTPUT_LEN; pub fn hash_password(secret: &[u8], salt: &[u8], iterations: u32) -> Vec { diff --git a/src/db/models/organization.rs b/src/db/models/organization.rs index 0885dd48..af273804 100644 --- a/src/db/models/organization.rs +++ b/src/db/models/organization.rs @@ -87,7 +87,7 @@ impl MembershipType { impl Ord for MembershipType { fn cmp(&self, other: &MembershipType) -> Ordering { // For easy comparison, map each variant to an access level (where 0 is lowest). - static ACCESS_LEVEL: [i32; 4] = [ + const ACCESS_LEVEL: [i32; 4] = [ 3, // Owner 2, // Admin 0, // User @@ -216,7 +216,7 @@ impl Organization { // The number 128 should be fine, it is well within the range of an i32 // The same goes for the database where we only use INTEGER (the same as an i32) // It should also provide enough room for 100+ types, which i doubt will ever happen. -static ACTIVATE_REVOKE_DIFF: i32 = 128; +const ACTIVATE_REVOKE_DIFF: i32 = 128; impl Membership { pub fn new(user_uuid: UserId, org_uuid: OrganizationId) -> Self {