Clippy: Fix manual_is_ascii_check

This commit is contained in:
Serial 2022-12-27 13:41:53 -05:00
parent 7f085c0632
commit 939f3f2f0d
No known key found for this signature in database
GPG key ID: DA95198DC17C4568
4 changed files with 5 additions and 8 deletions

View file

@ -41,7 +41,7 @@ impl FrameID {
pub(crate) fn verify_id(id_str: &str) -> Result<()> { pub(crate) fn verify_id(id_str: &str) -> Result<()> {
for c in id_str.chars() { for c in id_str.chars() {
if !('A'..='Z').contains(&c) && !('0'..='9').contains(&c) { if !c.is_ascii_uppercase() && !c.is_ascii_digit() {
return Err(ID3v2Error::new(ID3v2ErrorKind::BadFrameID).into()); return Err(ID3v2Error::new(ID3v2ErrorKind::BadFrameID).into());
} }
} }
@ -59,7 +59,7 @@ impl TryFrom<&ItemKey> for FrameID {
if unknown.len() == 4 if unknown.len() == 4
&& unknown && unknown
.chars() .chars()
.all(|c| ('A'..='Z').contains(&c) || ('0'..='9').contains(&c)) => .all(|c| c.is_ascii_uppercase() || c.is_ascii_digit()) =>
{ {
Ok(Self::Valid(unknown.clone())) Ok(Self::Valid(unknown.clone()))
}, },

View file

@ -42,7 +42,7 @@ impl LanguageFrame {
pub fn as_bytes(&self) -> Result<Vec<u8>> { pub fn as_bytes(&self) -> Result<Vec<u8>> {
let mut bytes = vec![self.encoding as u8]; let mut bytes = vec![self.encoding as u8];
if self.language.len() != 3 || self.language.iter().any(|c| !(b'a'..=b'z').contains(&c)) { if self.language.len() != 3 || self.language.iter().any(|c| !c.is_ascii_lowercase()) {
return Err(ID3v2Error::new(ID3v2ErrorKind::Other( return Err(ID3v2Error::new(ID3v2ErrorKind::Other(
"Invalid frame language found (expected 3 ascii characters)", "Invalid frame language found (expected 3 ascii characters)",
)) ))

View file

@ -192,10 +192,7 @@ impl SynchronizedText {
let mut data = vec![information.encoding as u8]; let mut data = vec![information.encoding as u8];
if information.language.len() == 3 if information.language.len() == 3
&& information && information.language.chars().all(|c| c.is_ascii_lowercase())
.language
.chars()
.all(|c| ('a'..='z').contains(&c))
{ {
data.write_all(information.language.as_bytes())?; data.write_all(information.language.as_bytes())?;
data.write_u8(information.timestamp_format as u8)?; data.write_u8(information.timestamp_format as u8)?;

View file

@ -39,5 +39,5 @@ pub(super) fn verify_key(key: &str) -> bool {
key.len() == 4 key.len() == 4
&& key && key
.chars() .chars()
.all(|c| ('A'..='Z').contains(&c) || ('0'..='9').contains(&c)) .all(|c| c.is_ascii_uppercase() || c.is_ascii_digit())
} }