From: Tim "S.D.Eagle" Zeitz Date: Tue, 6 Jul 2021 09:13:48 +0000 (+0200) Subject: refactor X-Git-Url: https://i11git.iti.kit.edu/anon-gitweb/?p=Mitarbeiter%2FTim-Zeitz%2Fstud-rust-base.git;a=commitdiff_plain;h=7e14e0703289af36efa95d687c71116a7a53a450 refactor --- diff --git a/src/bin/compare_vector.rs b/src/bin/compare_vector.rs index 2f566ed..0a18492 100644 --- a/src/bin/compare_vector.rs +++ b/src/bin/compare_vector.rs @@ -2,10 +2,7 @@ use stud_rust_base::{io::*, cli::CliErr}; use std::{env, fmt::Display, error::Error}; fn main() -> Result<(), Box> { - let mut args = env::args(); - args.next(); - - match &args.collect::>()[..] { + match &env::args().skip(1).collect::>()[..] { [data_type, input1, input2] => { match data_type.as_ref() { "i8" => { compare_values(&Vec::::load_from(input1)?, &Vec::::load_from(input2)?); Ok(()) }, diff --git a/src/bin/decode_vector.rs b/src/bin/decode_vector.rs index 4dca2e7..68d5bb2 100644 --- a/src/bin/decode_vector.rs +++ b/src/bin/decode_vector.rs @@ -2,10 +2,7 @@ use stud_rust_base::{io::*, cli::CliErr}; use std::{env, error::Error}; fn main() -> Result<(), Box> { - let mut args = env::args(); - args.next(); - - match &args.collect::>()[..] { + match &env::args().skip(1).collect::>()[..] { [data_type, input] => { match data_type.as_ref() { "i8" => { print_values(Vec::::load_from(input)?); Ok(()) }, diff --git a/src/bin/encode_vector.rs b/src/bin/encode_vector.rs index a51a63a..d8235bd 100644 --- a/src/bin/encode_vector.rs +++ b/src/bin/encode_vector.rs @@ -2,10 +2,7 @@ use stud_rust_base::{io::*, cli::CliErr}; use std::{env, error::Error}; fn main() -> Result<(), Box> { - let mut args = env::args(); - args.next(); - - match &args.collect::>()[..] { + match &env::args().skip(1).collect::>()[..] { [data_type, output] => { match data_type.as_ref() { "i8" => { parse_input::()?.write_to(output)?; Ok(()) }, diff --git a/src/bin/example.rs b/src/bin/example.rs index 68056b8..667bff3 100644 --- a/src/bin/example.rs +++ b/src/bin/example.rs @@ -3,10 +3,7 @@ use stud_rust_base::{io::*, time::report_time, types::*}; use std::{env, error::Error, path::Path}; fn main() -> Result<(), Box> { - let mut args = env::args(); - args.next(); - - let arg = &args.next().expect("No directory arg given"); + let arg = &env::args().skip(1).next().expect("No directory arg given"); let path = Path::new(arg); let first_out = Vec::::load_from(path.join("first_out"))?;