Fixed *more* clippy warnings

This commit is contained in:
G2-Games 2024-06-19 11:57:22 -05:00
parent 8d4a842a37
commit 2a1d975dce
4 changed files with 35 additions and 24 deletions

View file

@ -15,6 +15,7 @@ const BULK_WRITE_ENDPOINT: u8 = 0x02;
const BULK_READ_ENDPOINT: u8 = 0x81; const BULK_READ_ENDPOINT: u8 = 0x81;
nofmt::pls! { // Skip formatting the following info nofmt::pls! { // Skip formatting the following info
/// Device IDs for use in matching existing devices
pub static DEVICE_IDS: &[DeviceId] = &[ pub static DEVICE_IDS: &[DeviceId] = &[
DeviceId { vendor_id: 0x04dd, product_id: 0x7202, name: Some("Sharp IM-MT899H") }, DeviceId { vendor_id: 0x04dd, product_id: 0x7202, name: Some("Sharp IM-MT899H") },
DeviceId { vendor_id: 0x04dd, product_id: 0x9013, name: Some("Sharp IM-DR400") }, DeviceId { vendor_id: 0x04dd, product_id: 0x9013, name: Some("Sharp IM-DR400") },
@ -65,6 +66,7 @@ pub static DEVICE_IDS: &[DeviceId] = &[
]; ];
} }
/// Device IDs for use with [cross_usb]
pub static DEVICE_IDS_CROSSUSB: Lazy<Box<[cross_usb::DeviceFilter]>> = Lazy::new(|| { pub static DEVICE_IDS_CROSSUSB: Lazy<Box<[cross_usb::DeviceFilter]>> = Lazy::new(|| {
DEVICE_IDS DEVICE_IDS
.iter() .iter()
@ -136,7 +138,7 @@ impl NetMD {
if device_type.vendor_id == model.vendor_id if device_type.vendor_id == model.vendor_id
&& device_type.product_id == model.product_id && device_type.product_id == model.product_id
{ {
model.name = device_type.name.clone(); model.name = device_type.name;
break; break;
} }
} }

View file

@ -398,11 +398,7 @@ impl NetMDContext {
new_fw_name: Option<&str>, new_fw_name: Option<&str>,
) -> Result<(), Box<dyn Error>> { ) -> Result<(), Box<dyn Error>> {
let new_name = sanitize_half_width_title(new_name); let new_name = sanitize_half_width_title(new_name);
let new_fw_name = if let Some(name) = new_fw_name { let new_fw_name = new_fw_name.map(sanitize_full_width_title);
Some(sanitize_full_width_title(name))
} else {
None
};
let old_name = self.interface.disc_title(false).await?; let old_name = self.interface.disc_title(false).await?;
let old_fw_name = self.interface.disc_title(true).await?; let old_fw_name = self.interface.disc_title(true).await?;

View file

@ -76,12 +76,12 @@ pub enum Encoding {
LP4 = 0x93, LP4 = 0x93,
} }
impl ToString for Encoding { impl std::fmt::Display for Encoding {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Encoding::SP => String::from("sp"), Encoding::SP => write!(f, "sp"),
Encoding::LP2 => String::from("lp2"), Encoding::LP2 => write!(f, "lp2"),
Encoding::LP4 => String::from("lp4"), Encoding::LP4 => write!(f, "lp4"),
} }
} }
} }
@ -92,11 +92,11 @@ pub enum Channels {
Stereo = 0x00, Stereo = 0x00,
} }
impl ToString for Channels { impl std::fmt::Display for Channels {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Channels::Mono => String::from("mono"), Channels::Mono => write!(f, "mono"),
Channels::Stereo => String::from("stereo"), Channels::Stereo => write!(f, "stereo"),
} }
} }
} }
@ -112,11 +112,11 @@ pub enum TrackFlag {
Unprotected = 0x00, Unprotected = 0x00,
} }
impl ToString for TrackFlag { impl std::fmt::Display for TrackFlag {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
TrackFlag::Protected => String::from("protected"), TrackFlag::Protected => write!(f, "protected"),
TrackFlag::Unprotected => String::from("unprotected"), TrackFlag::Unprotected => write!(f, "unprotected"),
} }
} }
} }

View file

@ -1,6 +1,7 @@
use phf::phf_map; use phf::phf_map;
pub static MAPPINGS_JP: phf::Map<&'static str, &'static str> = phf_map![ /// Mappings to convert to fullwidth from half width
pub static MAPPINGS_JP: phf::Map<&str, &str> = phf_map![
"!" =>"", "!" =>"",
"\"" =>"", "\"" =>"",
"#" =>"", "#" =>"",
@ -191,7 +192,9 @@ pub static MAPPINGS_JP: phf::Map<&'static str, &'static str> = phf_map![
"" =>"", "" =>"",
"" =>"" "" =>""
]; ];
pub static MAPPINGS_RU: phf::Map<&'static str, &'static str> = phf_map![
/// Mappings to romanize Russian
pub static MAPPINGS_RU: phf::Map<&str, &str> = phf_map![
"а" =>"a", "а" =>"a",
"б" =>"b", "б" =>"b",
"в" =>"v", "в" =>"v",
@ -259,7 +262,9 @@ pub static MAPPINGS_RU: phf::Map<&'static str, &'static str> = phf_map![
"Ю" =>"Iu", "Ю" =>"Iu",
"Я" =>"Ia" "Я" =>"Ia"
]; ];
pub static MAPPINGS_DE: phf::Map<&'static str, &'static str> = phf_map![
/// Mappings to remove accents for German
pub static MAPPINGS_DE: phf::Map<&str, &str> = phf_map![
"Ä" => "Ae", "Ä" => "Ae",
"ä" => "ae", "ä" => "ae",
"Ö" => "Oe", "Ö" => "Oe",
@ -268,7 +273,9 @@ pub static MAPPINGS_DE: phf::Map<&'static str, &'static str> = phf_map![
"ü" => "ue", "ü" => "ue",
"ß" => "ss" "ß" => "ss"
]; ];
pub static MAPPINGS_HW: phf::Map<&'static str, &'static str> = phf_map![
/// Mappings to make Japanese half width
pub static MAPPINGS_HW: phf::Map<&str, &str> = phf_map![
"" =>"-", "" =>"-",
"" =>"-", "" =>"-",
"" =>"", "" =>"",
@ -548,7 +555,9 @@ pub static MAPPINGS_HW: phf::Map<&'static str, &'static str> = phf_map![
"" =>"", "" =>"",
"" =>"", "" =>"",
]; ];
pub static ALLOWED_HW_KANA: &[&'static str] = &[
/// A list of allowed half width kana
pub static ALLOWED_HW_KANA: &[&str] = &[
"-", "-", "", "", "", "", "", "", "", "", "", "", "", "ガ", "", "ギ", "", "グ", "-", "-", "", "", "", "", "", "", "", "", "", "", "", "ガ", "", "ギ", "", "グ",
"", "ゲ", "", "ゴ", "", "ザ", "", "ジ", "", "ズ", "", "ゼ", "ソ", "ゾ", "", "ダ", "", "", "ゲ", "", "ゴ", "", "ザ", "", "ジ", "", "ズ", "", "ゼ", "ソ", "ゾ", "", "ダ", "",
"ヂ", "", "", "ヅ", "", "デ", "", "ド", "", "", "", "", "", "", "バ", "パ", "", "ヂ", "", "", "ヅ", "", "デ", "", "ド", "", "", "", "", "", "", "バ", "パ", "",
@ -566,6 +575,8 @@ pub static ALLOWED_HW_KANA: &[&'static str] = &[
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "ヴ", "", "", "", "", "", "", "", "ヴ", "", "",
]; ];
/// Characters which take up more than one byte
pub static MULTI_BYTE_CHARS: phf::Map<char, u8> = phf_map![ pub static MULTI_BYTE_CHARS: phf::Map<char, u8> = phf_map![
'ガ' => 1, 'ガ' => 1,
'ギ' => 1, 'ギ' => 1,
@ -634,6 +645,8 @@ pub static MULTI_BYTE_CHARS: phf::Map<char, u8> = phf_map![
'ゝ' => 1, 'ゝ' => 1,
'ゞ' => 1 'ゞ' => 1
]; ];
/// Half width to full width conversion for group ranges
pub static HW_TO_FW_RANGE_MAP: phf::Map<char, char> = phf_map![ pub static HW_TO_FW_RANGE_MAP: phf::Map<char, char> = phf_map![
'0' => '', '0' => '',
'1' => '', '1' => '',