Browse Source

Apply cargo check suggestions

Apply nightly lints
I updated my toolchain to 1.66-nightly to fix all the files
pull/78/head
TechiePi 2 years ago
parent
commit
accf99b2bb
  1. 2
      ctru-rs/build.rs
  2. 14
      ctru-rs/examples/file-explorer.rs
  3. 2
      ctru-rs/examples/hashmaps.rs
  4. 10
      ctru-rs/examples/network-sockets.rs
  5. 2
      ctru-rs/examples/software-keyboard.rs
  6. 4
      ctru-rs/examples/time-rtc.rs
  7. 6
      ctru-rs/src/error.rs
  8. 2
      ctru-rs/src/services/fs.rs

2
ctru-rs/build.rs

@ -28,5 +28,5 @@ fn main() {
println!("cargo:rustc-cfg=romfs_exists"); println!("cargo:rustc-cfg=romfs_exists");
} }
println!("cargo:rerun-if-changed={}", manifest_dir); println!("cargo:rerun-if-changed={manifest_dir}");
} }

14
ctru-rs/examples/file-explorer.rs

@ -96,7 +96,7 @@ impl<'a> FileExplorer<'a> {
} }
} }
Err(e) => { 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() { for (i, entry) in dir_listing.enumerate() {
match entry { match entry {
Ok(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); self.entries.push(entry);
if (i + 1) % 20 == 0 { if (i + 1) % 20 == 0 {
@ -118,7 +118,7 @@ impl<'a> FileExplorer<'a> {
} }
} }
Err(e) => { Err(e) => {
println!("{} - Error: {}", i, e); println!("{i} - Error: {e}");
} }
} }
} }
@ -132,7 +132,7 @@ impl<'a> FileExplorer<'a> {
println!("{0:->80}", ""); println!("{0:->80}", "");
} }
Err(err) => { Err(err) => {
println!("Error reading file: {}", err); println!("Error reading file: {err}");
} }
} }
} }
@ -175,7 +175,7 @@ impl<'a> FileExplorer<'a> {
unreachable!() unreachable!()
} }
Err(e) => { 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() { let next_path_index: usize = match next_path_index.parse() {
Ok(index) => index, Ok(index) => index,
Err(e) => { Err(e) => {
println!("Number parsing error: {}", e); println!("Number parsing error: {e}");
return; return;
} }
}; };
@ -205,7 +205,7 @@ impl<'a> FileExplorer<'a> {
fn set_exact_path(&mut self, new_path_str: String) { fn set_exact_path(&mut self, new_path_str: String) {
let new_path = Path::new(&new_path_str); let new_path = Path::new(&new_path_str);
if !new_path.is_dir() { if !new_path.is_dir() {
println!("Not a directory: {}", new_path_str); println!("Not a directory: {new_path_str}");
return; return;
} }

2
ctru-rs/examples/hashmaps.rs

@ -17,7 +17,7 @@ fn main() {
map.insert("Another key?", 543); map.insert("Another key?", 543);
map.remove("A Key!"); map.remove("A Key!");
println!("{:#?}", map); println!("{map:#?}");
while apt.main_loop() { while apt.main_loop() {
gfx.flush_buffers(); gfx.flush_buffers();

10
ctru-rs/examples/network-sockets.rs

@ -25,19 +25,19 @@ fn main() {
match server.accept() { match server.accept() {
Ok((mut stream, socket_addr)) => { Ok((mut stream, socket_addr)) => {
println!("Got connection from {}", socket_addr); println!("Got connection from {socket_addr}");
let mut buf = [0u8; 4096]; let mut buf = [0u8; 4096];
match stream.read(&mut buf) { match stream.read(&mut buf) {
Ok(_) => { Ok(_) => {
let req_str = String::from_utf8_lossy(&buf); let req_str = String::from_utf8_lossy(&buf);
println!("{}", req_str); println!("{req_str}");
} }
Err(e) => { Err(e) => {
if e.kind() == io::ErrorKind::WouldBlock { if e.kind() == io::ErrorKind::WouldBlock {
println!("Note: Reading the connection returned ErrorKind::WouldBlock.") println!("Note: Reading the connection returned ErrorKind::WouldBlock.")
} else { } 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\n<html><body>Hello world</body></html>\r\n"; let response = b"HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n<html><body>Hello world</body></html>\r\n";
if let Err(e) = stream.write(response) { if let Err(e) = stream.write(response) {
println!("Error writing http response: {}", e); println!("Error writing http response: {e}");
} }
stream.shutdown(Shutdown::Both).unwrap(); stream.shutdown(Shutdown::Both).unwrap();
@ -53,7 +53,7 @@ fn main() {
Err(e) => match e.kind() { Err(e) => match e.kind() {
std::io::ErrorKind::WouldBlock => {} std::io::ErrorKind::WouldBlock => {}
_ => { _ => {
println!("Error accepting connection: {}", e); println!("Error accepting connection: {e}");
std::thread::sleep(Duration::from_secs(2)); std::thread::sleep(Duration::from_secs(2));
} }
}, },

2
ctru-rs/examples/software-keyboard.rs

@ -29,7 +29,7 @@ fn main() {
// Raise the software keyboard. You can perform different actions depending on which // Raise the software keyboard. You can perform different actions depending on which
// software button the user pressed // software button the user pressed
match keyboard.get_utf8(&mut text) { 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::Left) => println!("Cancelled"),
Ok(Button::Middle) => println!("How did you even press this?"), Ok(Button::Middle) => println!("How did you even press this?"),
Err(_) => println!("Oh noes, an error happened!"), Err(_) => println!("Oh noes, an error happened!"),

4
ctru-rs/examples/time-rtc.rs

@ -33,8 +33,8 @@ fn main() {
let day = cur_time.day(); let day = cur_time.day();
let year = cur_time.year(); let year = cur_time.year();
println!("\x1b[1;1H{:0>2}:{:0>2}:{:0>2}", hours, minutes, seconds); println!("\x1b[1;1H{hours:0>2}:{minutes:0>2}:{seconds:0>2}");
println!("{} {} {} {}", weekday, month, day, year); println!("{weekday} {month} {day} {year}");
// Flush and swap framebuffers // Flush and swap framebuffers
gfx.flush_buffers(); gfx.flush_buffers();

6
ctru-rs/src/error.rs

@ -87,7 +87,7 @@ impl fmt::Debug for Error {
match self { match self {
&Self::Os(err) => f &Self::Os(err) => f
.debug_struct("Error") .debug_struct("Error")
.field("raw", &format_args!("{:#08X}", err)) .field("raw", &format_args!("{err:#08X}"))
.field("description", &R_DESCRIPTION(err)) .field("description", &R_DESCRIPTION(err))
.field("module", &R_MODULE(err)) .field("module", &R_MODULE(err))
.field("summary", &R_SUMMARY(err)) .field("summary", &R_SUMMARY(err))
@ -106,8 +106,8 @@ impl fmt::Debug for Error {
impl fmt::Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self { match self {
&Self::Os(err) => write!(f, "libctru result code: 0x{:08X}", err), &Self::Os(err) => write!(f, "libctru result code: 0x{err:08X}"),
Self::Libc(err) => write!(f, "{}", err), Self::Libc(err) => write!(f, "{err}"),
Self::ServiceAlreadyActive => write!(f, "Service already active"), Self::ServiceAlreadyActive => write!(f, "Service already active"),
Self::OutputAlreadyRedirected => { Self::OutputAlreadyRedirected => {
write!(f, "output streams are already redirected to 3dslink") write!(f, "output streams are already redirected to 3dslink")

2
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` /// The full path is created by joining the original path to `read_dir`
/// with the filename of this entry. /// with the filename of this entry.
pub fn path(&self) -> PathBuf { 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. /// Return the metadata for the file that this entry points at.

Loading…
Cancel
Save