Skip to content

Commit

Permalink
Replace manual cloning of variable with cloning iterator in `Tag::fro…
Browse files Browse the repository at this point in the history
…m_str`
  • Loading branch information
ThatNintendoNerd committed Feb 13, 2024
1 parent 20c3843 commit b9b3183
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lvd_lib/src/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ use crate::Version;
/// - Letter values must range from 0 to 26, inclusively.
/// - Number must range from 0 to 9999, inclusively.
///
/// Likewise, when converting from a string to a `Tag`'s native representation,
/// the string should follow these restrictions:
/// Likewise, when converting from a string to a `Tag`, the string should follow these restrictions:
///
/// - Must have a length of seven characters.
/// - Must begin with three capital letters, underscores, or any combination of the two.
Expand Down Expand Up @@ -95,9 +94,7 @@ impl FromStr for Tag {
let mut letters = [0; Self::LETTER_COUNT];
let mut digits = [0; Self::DIGIT_COUNT];

for (index, letter) in letters_str.iter().enumerate() {
let letter = *letter;

for (index, letter) in letters_str.iter().cloned().enumerate() {
if letter == b'_' {
letters[index] = 0;
continue;
Expand All @@ -111,9 +108,7 @@ impl FromStr for Tag {
return Err(Self::Err::LetterNotFound(letter as char));
}

for (index, digit) in digits_str.iter().enumerate() {
let digit = *digit;

for (index, digit) in digits_str.iter().cloned().enumerate() {
if u8::wrapping_sub(digit, Self::DIGIT_CHAR_MIN) < Self::DIGIT_MAX {
digits[index] = digit - Self::DIGIT_CHAR_MIN;
continue;
Expand Down

0 comments on commit b9b3183

Please sign in to comment.