From d452c64894d5067277a8842bbf0c8c9365f6b137 Mon Sep 17 00:00:00 2001
From: Daniel Schadt <kingdread@gmx.de>
Date: Sun, 8 Dec 2019 03:40:00 +0100
Subject: use iter_mut instead of indexing

---
 src/bt.rs | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

(limited to 'src')

diff --git a/src/bt.rs b/src/bt.rs
index f4ede80..f3e2090 100644
--- a/src/bt.rs
+++ b/src/bt.rs
@@ -299,7 +299,7 @@ impl BuildTemplate {
     ///
     /// This needs api acccess in order to fetch the relevant skill and trait data.
     pub fn from_chatlink(api: &mut Api, input: &str) -> Result<BuildTemplate, ChatlinkError> {
-        if !input.starts_with("[&") || !input.ends_with("]") {
+        if !input.starts_with("[&") || !input.ends_with(']') {
             return Err(ChatlinkError::MalformedInput);
         }
         let inner = &input[2..input.len() - 1];
@@ -314,7 +314,7 @@ impl BuildTemplate {
         let profession = Profession::try_from(bytes.remove(0))?;
 
         let mut traitlines = BuildTemplate::empty(profession).traitlines;
-        for i in 0..TRAITLINE_COUNT {
+        for i in traitlines.iter_mut() {
             let spec_id = bytes.remove(0);
             let trait_choices = bytes.remove(0);
             if spec_id == 0 {
@@ -325,11 +325,11 @@ impl BuildTemplate {
             let c_0 = TraitChoice::try_from(trait_choices & 0x3)?;
             let c_1 = TraitChoice::try_from((trait_choices >> 2) & 0x3)?;
             let c_2 = TraitChoice::try_from((trait_choices >> 4) & 0x3)?;
-            traitlines[i] = Some((spec, [c_0, c_1, c_2]));
+            *i = Some((spec, [c_0, c_1, c_2]));
         }
 
         let mut skills = BuildTemplate::empty(profession).skills;
-        for i in 0..SKILL_COUNT {
+        for i in skills.iter_mut() {
             // Terrestrial
             let byte_1 = bytes.remove(0);
             let byte_2 = bytes.remove(0);
@@ -337,7 +337,7 @@ impl BuildTemplate {
             if palette_id != 0 {
                 let skill_id = palette_id_to_skill_id(palette_id);
                 let skill = api.get_skills(&[skill_id])?.remove(0);
-                skills[i] = Some(skill);
+                *i = Some(skill);
             }
 
             // Aquatic
@@ -348,8 +348,8 @@ impl BuildTemplate {
         let extra_data = match profession {
             Profession::Revenant => {
                 let mut legends = [Legend::None; LEGEND_COUNT];
-                for i in 0..LEGEND_COUNT {
-                    legends[i] = Legend::try_from(bytes.remove(0))?;
+                for i in legends.iter_mut() {
+                    *i = Legend::try_from(bytes.remove(0))?;
                 }
                 ExtraData::Legends(legends)
             }
-- 
cgit v1.2.3