From accf99b2bb6ac264430f4f04e263fd27243e851a Mon Sep 17 00:00:00 2001 From: TechiePi Date: Wed, 26 Oct 2022 17:19:38 +0200 Subject: [PATCH] Apply cargo check suggestions Apply nightly lints I updated my toolchain to 1.66-nightly to fix all the files --- ctru-rs/build.rs | 2 +- ctru-rs/examples/file-explorer.rs | 14 +++++++------- ctru-rs/examples/hashmaps.rs | 2 +- ctru-rs/examples/network-sockets.rs | 10 +++++----- ctru-rs/examples/software-keyboard.rs | 2 +- ctru-rs/examples/time-rtc.rs | 4 ++-- ctru-rs/src/error.rs | 6 +++--- ctru-rs/src/services/fs.rs | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ctru-rs/build.rs b/ctru-rs/build.rs index ecdef33..f65d194 100644 --- a/ctru-rs/build.rs +++ b/ctru-rs/build.rs @@ -28,5 +28,5 @@ fn main() { println!("cargo:rustc-cfg=romfs_exists"); } - println!("cargo:rerun-if-changed={}", manifest_dir); + println!("cargo:rerun-if-changed={manifest_dir}"); } diff --git a/ctru-rs/examples/file-explorer.rs b/ctru-rs/examples/file-explorer.rs index ff6296f..1cff988 100644 --- a/ctru-rs/examples/file-explorer.rs +++ b/ctru-rs/examples/file-explorer.rs @@ -96,7 +96,7 @@ impl<'a> FileExplorer<'a> { } } Err(e) => { - println!("Failed to read {}: {}", self.path.display(), e) + println!("Failed to read {}: {e}", self.path.display()) } }; @@ -110,7 +110,7 @@ impl<'a> FileExplorer<'a> { for (i, entry) in dir_listing.enumerate() { match entry { Ok(entry) => { - println!("{:2} - {}", i, entry.file_name().to_string_lossy()); + println!("{i:2} - {}", entry.file_name().to_string_lossy()); self.entries.push(entry); if (i + 1) % 20 == 0 { @@ -118,7 +118,7 @@ impl<'a> FileExplorer<'a> { } } Err(e) => { - println!("{} - Error: {}", i, e); + println!("{i} - Error: {e}"); } } } @@ -132,7 +132,7 @@ impl<'a> FileExplorer<'a> { println!("{0:->80}", ""); } Err(err) => { - println!("Error reading file: {}", err); + println!("Error reading file: {err}"); } } } @@ -175,7 +175,7 @@ impl<'a> FileExplorer<'a> { unreachable!() } Err(e) => { - panic!("Error: {:?}", e) + panic!("Error: {e:?}") } } } @@ -184,7 +184,7 @@ impl<'a> FileExplorer<'a> { let next_path_index: usize = match next_path_index.parse() { Ok(index) => index, Err(e) => { - println!("Number parsing error: {}", e); + println!("Number parsing error: {e}"); return; } }; @@ -205,7 +205,7 @@ impl<'a> FileExplorer<'a> { fn set_exact_path(&mut self, new_path_str: String) { let new_path = Path::new(&new_path_str); if !new_path.is_dir() { - println!("Not a directory: {}", new_path_str); + println!("Not a directory: {new_path_str}"); return; } diff --git a/ctru-rs/examples/hashmaps.rs b/ctru-rs/examples/hashmaps.rs index 3218dc5..694752c 100644 --- a/ctru-rs/examples/hashmaps.rs +++ b/ctru-rs/examples/hashmaps.rs @@ -17,7 +17,7 @@ fn main() { map.insert("Another key?", 543); map.remove("A Key!"); - println!("{:#?}", map); + println!("{map:#?}"); while apt.main_loop() { gfx.flush_buffers(); diff --git a/ctru-rs/examples/network-sockets.rs b/ctru-rs/examples/network-sockets.rs index a0b64d0..89a1212 100644 --- a/ctru-rs/examples/network-sockets.rs +++ b/ctru-rs/examples/network-sockets.rs @@ -25,19 +25,19 @@ fn main() { match server.accept() { Ok((mut stream, socket_addr)) => { - println!("Got connection from {}", socket_addr); + println!("Got connection from {socket_addr}"); let mut buf = [0u8; 4096]; match stream.read(&mut buf) { Ok(_) => { let req_str = String::from_utf8_lossy(&buf); - println!("{}", req_str); + println!("{req_str}"); } Err(e) => { if e.kind() == io::ErrorKind::WouldBlock { println!("Note: Reading the connection returned ErrorKind::WouldBlock.") } else { - println!("Unable to read stream: {}", e) + println!("Unable to read stream: {e}") } } } @@ -45,7 +45,7 @@ fn main() { let response = b"HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\n\r\nHello world\r\n"; if let Err(e) = stream.write(response) { - println!("Error writing http response: {}", e); + println!("Error writing http response: {e}"); } stream.shutdown(Shutdown::Both).unwrap(); @@ -53,7 +53,7 @@ fn main() { Err(e) => match e.kind() { std::io::ErrorKind::WouldBlock => {} _ => { - println!("Error accepting connection: {}", e); + println!("Error accepting connection: {e}"); std::thread::sleep(Duration::from_secs(2)); } }, diff --git a/ctru-rs/examples/software-keyboard.rs b/ctru-rs/examples/software-keyboard.rs index b830811..888a157 100644 --- a/ctru-rs/examples/software-keyboard.rs +++ b/ctru-rs/examples/software-keyboard.rs @@ -29,7 +29,7 @@ fn main() { // Raise the software keyboard. You can perform different actions depending on which // software button the user pressed match keyboard.get_utf8(&mut text) { - Ok(Button::Right) => println!("You entered: {}", text), + Ok(Button::Right) => println!("You entered: {text}"), Ok(Button::Left) => println!("Cancelled"), Ok(Button::Middle) => println!("How did you even press this?"), Err(_) => println!("Oh noes, an error happened!"), diff --git a/ctru-rs/examples/time-rtc.rs b/ctru-rs/examples/time-rtc.rs index 1554a21..219abda 100644 --- a/ctru-rs/examples/time-rtc.rs +++ b/ctru-rs/examples/time-rtc.rs @@ -33,8 +33,8 @@ fn main() { let day = cur_time.day(); let year = cur_time.year(); - println!("\x1b[1;1H{:0>2}:{:0>2}:{:0>2}", hours, minutes, seconds); - println!("{} {} {} {}", weekday, month, day, year); + println!("\x1b[1;1H{hours:0>2}:{minutes:0>2}:{seconds:0>2}"); + println!("{weekday} {month} {day} {year}"); // Flush and swap framebuffers gfx.flush_buffers(); diff --git a/ctru-rs/src/error.rs b/ctru-rs/src/error.rs index 650ab7a..5054ada 100644 --- a/ctru-rs/src/error.rs +++ b/ctru-rs/src/error.rs @@ -87,7 +87,7 @@ impl fmt::Debug for Error { match self { &Self::Os(err) => f .debug_struct("Error") - .field("raw", &format_args!("{:#08X}", err)) + .field("raw", &format_args!("{err:#08X}")) .field("description", &R_DESCRIPTION(err)) .field("module", &R_MODULE(err)) .field("summary", &R_SUMMARY(err)) @@ -106,8 +106,8 @@ impl fmt::Debug for Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - &Self::Os(err) => write!(f, "libctru result code: 0x{:08X}", err), - Self::Libc(err) => write!(f, "{}", err), + &Self::Os(err) => write!(f, "libctru result code: 0x{err:08X}"), + Self::Libc(err) => write!(f, "{err}"), Self::ServiceAlreadyActive => write!(f, "Service already active"), Self::OutputAlreadyRedirected => { write!(f, "output streams are already redirected to 3dslink") diff --git a/ctru-rs/src/services/fs.rs b/ctru-rs/src/services/fs.rs index d86cb55..64da9c3 100644 --- a/ctru-rs/src/services/fs.rs +++ b/ctru-rs/src/services/fs.rs @@ -669,7 +669,7 @@ impl<'a> DirEntry<'a> { /// The full path is created by joining the original path to `read_dir` /// with the filename of this entry. pub fn path(&self) -> PathBuf { - self.root.join(&self.file_name()) + self.root.join(self.file_name()) } /// Return the metadata for the file that this entry points at.