mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-14 14:42:33 +00:00
Clippy: Fix manual_is_ascii_check
This commit is contained in:
parent
7f085c0632
commit
939f3f2f0d
4 changed files with 5 additions and 8 deletions
|
@ -41,7 +41,7 @@ impl FrameID {
|
|||
|
||||
pub(crate) fn verify_id(id_str: &str) -> Result<()> {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ impl TryFrom<&ItemKey> for FrameID {
|
|||
if unknown.len() == 4
|
||||
&& unknown
|
||||
.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()))
|
||||
},
|
||||
|
|
|
@ -42,7 +42,7 @@ impl LanguageFrame {
|
|||
pub fn as_bytes(&self) -> Result<Vec<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(
|
||||
"Invalid frame language found (expected 3 ascii characters)",
|
||||
))
|
||||
|
|
|
@ -192,10 +192,7 @@ impl SynchronizedText {
|
|||
let mut data = vec![information.encoding as u8];
|
||||
|
||||
if information.language.len() == 3
|
||||
&& information
|
||||
.language
|
||||
.chars()
|
||||
.all(|c| ('a'..='z').contains(&c))
|
||||
&& information.language.chars().all(|c| c.is_ascii_lowercase())
|
||||
{
|
||||
data.write_all(information.language.as_bytes())?;
|
||||
data.write_u8(information.timestamp_format as u8)?;
|
||||
|
|
|
@ -39,5 +39,5 @@ pub(super) fn verify_key(key: &str) -> bool {
|
|||
key.len() == 4
|
||||
&& key
|
||||
.chars()
|
||||
.all(|c| ('A'..='Z').contains(&c) || ('0'..='9').contains(&c))
|
||||
.all(|c| c.is_ascii_uppercase() || c.is_ascii_digit())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue