diff options
author | Daniel Schadt <kingdread@gmx.de> | 2019-12-08 03:40:00 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2019-12-08 03:40:00 +0100 |
commit | d452c64894d5067277a8842bbf0c8c9365f6b137 (patch) | |
tree | b6da1e0ab8b4f2750bb32c562afadc195ca06a55 | |
parent | 3613193f2ed2835bdd4a42e85211620d138b621e (diff) | |
download | kondou-d452c64894d5067277a8842bbf0c8c9365f6b137.tar.gz kondou-d452c64894d5067277a8842bbf0c8c9365f6b137.tar.bz2 kondou-d452c64894d5067277a8842bbf0c8c9365f6b137.zip |
use iter_mut instead of indexing
-rw-r--r-- | src/bt.rs | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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) } |