Index: src/command.rs ================================================================== --- src/command.rs +++ src/command.rs @@ -39,21 +39,21 @@ } pub async fn update(core: &Core, sender: telegram_bot::UserId, command: Vec<&str>) -> Result<()> { let mut source_id: Option = None; let at_least = "Requires at least 3 parameters."; - let first_word = command[0]; - let command = match first_word { + let mut i_command = command.iter(); + let first_word = i_command.next().context(at_least)?; + match *first_word { "/update" => { - source_id = Some(command[1].parse::() - .context(format!("I need a number, but got {}.", command[1]))?); - &command[2..] + let next_word = i_command.next().context(at_least)?; + source_id = Some(next_word.parse::() + .context(format!("I need a number, but got {}.", next_word))?); }, - "/add" => &command[1..], - _ => bail!("Passing {} is not possible here.", command[1]), + "/add" => {}, + _ => bail!("Passing {} is not possible here.", first_word), }; - let mut i_command = command.iter(); let (channel, url, iv_hash, url_re) = ( i_command.next().context(at_least)?, i_command.next().context(at_least)?, i_command.next(), i_command.next());