1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-04 15:07:47 +00:00

refactor/polish ~ fix cargo clippy complaints (use starts_with())

This commit is contained in:
Roy Ivy III 2019-12-26 15:39:54 -06:00
parent e676447b3d
commit 3bff70967c
2 changed files with 2 additions and 2 deletions

View file

@ -74,7 +74,7 @@ fn handle_obsolete(mut args: Vec<String>) -> (Vec<String>, Option<String>) {
while i < args.len() {
// this is safe because slice is valid when it is referenced
let slice = &args[i].clone();
if slice.chars().next().unwrap() == '-' && slice.len() > 1
if slice.starts_with('-') && slice.len() > 1
&& slice.chars().nth(1).unwrap().is_digit(10)
{
let val = &slice[1..];

View file

@ -72,7 +72,7 @@ fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<Stri
break;
}
_ => {
if arg.len() > 1 && arg.chars().next().unwrap() == '-' {
if arg.len() > 1 && arg.starts_with('-') {
let argptr: *const String = &arg; // escape from the borrow checker
let mut chiter = unsafe { &(*argptr)[..] }.chars().skip(1);
let mut ch = ' ';