pkstrings: clippy
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
b824fe6512
commit
0dcff8ed80
1 changed files with 9 additions and 12 deletions
|
@ -26,27 +26,24 @@ use std::error::Error as StdError;
|
|||
use std::ops::Deref;
|
||||
|
||||
const fn in_range(ord: u8) -> bool {
|
||||
match ord {
|
||||
0x00 |
|
||||
matches!(ord, 0x00 |
|
||||
0x49..=0x4c | 0x4e..=0x5f | // Control characters
|
||||
0x60..=0x78 | // Holdover from the japanese game
|
||||
0x79..=0x7f | // Text box borders
|
||||
0x80..=0xbf |
|
||||
0xe0..=0xff => true,
|
||||
_ => false,
|
||||
}
|
||||
0xe0..=0xff)
|
||||
}
|
||||
|
||||
const fn chrtohex(chr: &char) -> Option<u8> {
|
||||
Some(match chr {
|
||||
cap @ 'A'..='Z' => 0x80 - ('A' as u8) + (*cap as u8),
|
||||
cap @ 'A'..='Z' => 0x80 - b'A' + (*cap as u8),
|
||||
'(' => 0x9a,
|
||||
')' => 0x9b,
|
||||
':' => 0x9c,
|
||||
';' => 0x9d,
|
||||
'[' => 0x9e,
|
||||
']' => 0x9f,
|
||||
low @ 'a'..='z' => 0xa0 - ('a' as u8) + (*low as u8),
|
||||
low @ 'a'..='z' => 0xa0 - b'a' + (*low as u8),
|
||||
'\'' => 0xe0,
|
||||
'-' => 0xe3,
|
||||
'?' => 0xe6,
|
||||
|
@ -68,7 +65,7 @@ const fn chrtohex(chr: &char) -> Option<u8> {
|
|||
'/' => 0xf3,
|
||||
',' => 0xf4,
|
||||
'♀' => 0xf5,
|
||||
num @ '0'..='9' => 0xf6 - ('0' as u8) + (*num as u8),
|
||||
num @ '0'..='9' => 0xf6 - b'0' + (*num as u8),
|
||||
' ' => 0x7f,
|
||||
'@' => 0x50,
|
||||
_ => return None,
|
||||
|
@ -77,14 +74,14 @@ const fn chrtohex(chr: &char) -> Option<u8> {
|
|||
|
||||
const fn hextochr(hex: u8) -> Option<char> {
|
||||
Some(match hex {
|
||||
cap @ 0x80..=0x99 => (('A' as u8) + (cap - 0x80)) as char,
|
||||
cap @ 0x80..=0x99 => (b'A' + (cap - 0x80)) as char,
|
||||
0x9a => '(',
|
||||
0x9b => ')',
|
||||
0x9c => ':',
|
||||
0x9d => ';',
|
||||
0x9e => '[',
|
||||
0x9f => ']',
|
||||
low @ 0xa0..=0xb9 => (('a' as u8) + (low - 0xa0)) as char,
|
||||
low @ 0xa0..=0xb9 => (b'a' + (low - 0xa0)) as char,
|
||||
0xe0 => '\'',
|
||||
0xe3 => '-',
|
||||
0xe6 => '?',
|
||||
|
@ -99,7 +96,7 @@ const fn hextochr(hex: u8) -> Option<char> {
|
|||
0xf3 => '/',
|
||||
0xf4 => ',',
|
||||
0xf5 => '♀',
|
||||
num @ 0xf6..=0xff => (('0' as u8) + (num - 0xf6)) as char,
|
||||
num @ 0xf6..=0xff => (b'0' + (num - 0xf6)) as char,
|
||||
0x7f => ' ',
|
||||
0x50 => '@',
|
||||
_ => return None,
|
||||
|
@ -204,7 +201,7 @@ impl From<&PKString> for String {
|
|||
for ord in &pkstr.0 {
|
||||
match hextochr(*ord) {
|
||||
Some(chr) => buf.push(chr),
|
||||
None => buf.push(placeholder.clone()),
|
||||
None => buf.push(placeholder),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue