From d07bb7da416b7bbefaae1d9df7402e27a319fc80 Mon Sep 17 00:00:00 2001 From: DTB Date: Fri, 28 Jun 2024 08:33:31 -0600 Subject: [PATCH] swab(1): untested move to new getopt bindings --- src/swab.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/swab.rs b/src/swab.rs index ca944d9..d997ddf 100644 --- a/src/swab.rs +++ b/src/swab.rs @@ -49,20 +49,16 @@ fn main() -> ExitCode { let mut force = false; let mut wordsize: usize = 2; - loop { - match opts.next() { - None => break, - Some(opt) => - match opt { - Ok(Opt('f', None)) => force = true, - Ok(Opt('w', Some(arg))) => { - match arg.parse::() { - Ok(w) if w % 2 == 0 => { wordsize = w; () }, - _ => { return usage(&argv[0]); }, - } - }, - _ => { return usage(&argv[0]); } - } + while let Some(opt) = argv.getopt("fw:") { + match opt.opt() { + Ok("f") => force = true, + Ok("w") => { + match arg.parse::() { + Ok(w) if w % 2 == 0 => { wordsize = w; () }, + _ => { return usage(&argv[0]); }, + } + }, + _ => { return usage(&argv[0]); } } }