Skip to content

Commit 772db74

Browse files
refactor: replace static with const for global constants (#494)
1 parent 2f24653 commit 772db74

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

libs/hbb_common/src/keyboard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl FromStr for KeyboardMode {
2828

2929
impl KeyboardMode {
3030
pub fn iter() -> Iter<'static, KeyboardMode> {
31-
static KEYBOARD_MODES: [KeyboardMode; 4] = [
31+
const KEYBOARD_MODES: [KeyboardMode; 4] = [
3232
KeyboardMode::Legacy,
3333
KeyboardMode::Map,
3434
KeyboardMode::Translate,

src/peer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ lazy_static::lazy_static! {
1818
pub(crate) static ref USER_STATUS: RwLock<UserStatusMap> = Default::default();
1919
pub(crate) static ref IP_CHANGES: Mutex<IpChangesMap> = Default::default();
2020
}
21-
pub static IP_CHANGE_DUR: u64 = 180;
22-
pub static IP_CHANGE_DUR_X2: u64 = IP_CHANGE_DUR * 2;
23-
pub static DAY_SECONDS: u64 = 3600 * 24;
24-
pub static IP_BLOCK_DUR: u64 = 60;
21+
pub const IP_CHANGE_DUR: u64 = 180;
22+
pub const IP_CHANGE_DUR_X2: u64 = IP_CHANGE_DUR * 2;
23+
pub const DAY_SECONDS: u64 = 3600 * 24;
24+
pub const IP_BLOCK_DUR: u64 = 60;
2525

2626
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
2727
pub(crate) struct PeerInfo {

src/rendezvous_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type Sender = mpsc::UnboundedSender<Data>;
5858
type Receiver = mpsc::UnboundedReceiver<Data>;
5959
static ROTATION_RELAY_SERVER: AtomicUsize = AtomicUsize::new(0);
6060
type RelayServers = Vec<String>;
61-
static CHECK_RELAY_TIMEOUT: u64 = 3_000;
61+
const CHECK_RELAY_TIMEOUT: u64 = 3_000;
6262
static ALWAYS_USE_RELAY: AtomicBool = AtomicBool::new(false);
6363

6464
#[derive(Clone)]

0 commit comments

Comments
 (0)