From a373cf6a87931f3e239dcaa920506700cc35a682 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 16 Sep 2021 14:44:31 +0900 Subject: [PATCH] Apply cargo clippy fixes --- src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3917096..506d0de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,8 +96,8 @@ fn check_next_chars( )) } else if buf[idx] & 0b11110000 == 0b11100000 { if idx + 2 >= buf.len() { - for tidx in idx..buf.len() { - saved.push(buf[tidx]); + for c in buf.iter().skip(idx) { + saved.push(*c); } return Err(( String::from("Is three byte UTF-8, but not enough bytes provided"), @@ -113,8 +113,8 @@ fn check_next_chars( )) } else if buf[idx] & 0b11111000 == 0b11110000 { if idx + 2 >= buf.len() { - for tidx in idx..buf.len() { - saved.push(buf[tidx]); + for c in buf.iter().skip(idx) { + saved.push(*c); } return Err(( String::from("Is four byte UTF-8, but not enough bytes provided"), @@ -159,7 +159,7 @@ fn read_line( skip_count -= 1; continue; } - let next_char_result = check_next_chars(&mut buf_to_read, idx, saved); + let next_char_result = check_next_chars(&buf_to_read, idx, saved); if let Ok((c, s)) = next_char_result { if !init { prev_two.push(c); @@ -196,7 +196,7 @@ fn read_line( Err((String::from("Newline not reached"), result)) } -fn debug_write_albumart_to_file(data: &Vec) -> Result<(), String> { +fn debug_write_albumart_to_file(data: &[u8]) -> Result<(), String> { let mut f = File::create("albumartOut.jpg") .map_err(|_| String::from("Failed to open file for writing albumart"))?; f.write_all(data)