Skip to content

Commit

Permalink
Turn static LazyLock<Vec<_>> to const &[_]
Browse files Browse the repository at this point in the history
  • Loading branch information
nokyan committed Oct 25, 2024
1 parent 40a0e1d commit 9714c56
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/utils/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{
ffi::OsString,
fmt::Display,
path::{Path, PathBuf},
sync::LazyLock,
};

use anyhow::{Context, Result};
Expand All @@ -16,23 +15,21 @@ use super::{
};

// this is a vec because we don't look for exact matches but for if the device name starts with a certain string
static INTERFACE_TYPE_MAP: LazyLock<Vec<(&'static str, InterfaceType)>> = LazyLock::new(|| {
vec![
("bn", InterfaceType::Bluetooth),
("br", InterfaceType::Bridge),
("docker", InterfaceType::Docker),
("eth", InterfaceType::Ethernet),
("en", InterfaceType::Ethernet),
("ib", InterfaceType::InfiniBand),
("sl", InterfaceType::Slip),
("veth", InterfaceType::VirtualEthernet),
("virbr", InterfaceType::VmBridge),
("vpn", InterfaceType::Vpn),
("wg", InterfaceType::Wireguard),
("wl", InterfaceType::Wlan),
("ww", InterfaceType::Wwan),
]
});
const INTERFACE_TYPE_MAP: &[(&'static str, InterfaceType)] = &[
("bn", InterfaceType::Bluetooth),
("br", InterfaceType::Bridge),
("docker", InterfaceType::Docker),
("eth", InterfaceType::Ethernet),
("en", InterfaceType::Ethernet),
("ib", InterfaceType::InfiniBand),
("sl", InterfaceType::Slip),
("veth", InterfaceType::VirtualEthernet),
("virbr", InterfaceType::VmBridge),
("vpn", InterfaceType::Vpn),
("wg", InterfaceType::Wireguard),
("wl", InterfaceType::Wlan),
("ww", InterfaceType::Wwan),
];

#[derive(Debug)]
pub struct NetworkData {
Expand Down

0 comments on commit 9714c56

Please sign in to comment.