From fb38d8202f1d9ef3b33caa031470a84679f6a30b Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Fri, 19 Aug 2022 11:59:39 +0200 Subject: [PATCH] Fix formatting --- ctru-rs/examples/network-sockets.rs | 2 +- ctru-rs/examples/system-configuration.rs | 17 +++++++++++++---- ctru-rs/src/lib.rs | 2 -- ctru-rs/src/services/reference.rs | 9 +++++++-- ctru-sys/src/bin/docstring-to-rustdoc.rs | 11 ++++------- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ctru-rs/examples/network-sockets.rs b/ctru-rs/examples/network-sockets.rs index ac8953d..6526d41 100644 --- a/ctru-rs/examples/network-sockets.rs +++ b/ctru-rs/examples/network-sockets.rs @@ -43,7 +43,7 @@ fn main() { } else { println!("Unable to read stream: {}", e) } - }, + } } let response = b"HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\n\r\nHello world\r\n"; diff --git a/ctru-rs/examples/system-configuration.rs b/ctru-rs/examples/system-configuration.rs index 47e70c6..6f51c23 100644 --- a/ctru-rs/examples/system-configuration.rs +++ b/ctru-rs/examples/system-configuration.rs @@ -1,8 +1,8 @@ use ctru::console::Console; use ctru::gfx::Gfx; use ctru::services::apt::Apt; -use ctru::services::hid::{Hid, KeyPad}; use ctru::services::cfgu::Cfgu; +use ctru::services::hid::{Hid, KeyPad}; fn main() { ctru::init(); @@ -12,9 +12,18 @@ fn main() { let cfgu = Cfgu::init().expect("Couldn't obtain CFGU controller"); let _console = Console::init(gfx.top_screen.borrow_mut()); - println!("\x1b[0;0H{}", format!("Region: {:?}", cfgu.get_region().unwrap())); - println!("\x1b[10;0H{}", format!("Language: {:?}", cfgu.get_language().unwrap())); - println!("\x1b[20;0H{}", format!("Model: {:?}", cfgu.get_model().unwrap())); + println!( + "\x1b[0;0H{}", + format!("Region: {:?}", cfgu.get_region().unwrap()) + ); + println!( + "\x1b[10;0H{}", + format!("Language: {:?}", cfgu.get_language().unwrap()) + ); + println!( + "\x1b[20;0H{}", + format!("Model: {:?}", cfgu.get_model().unwrap()) + ); // Main loop while apt.main_loop() { diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index 0048306..5a4aaa9 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -4,8 +4,6 @@ #![feature(custom_test_frameworks)] #![test_runner(test_runner::run)] -// Test PR - extern "C" fn services_deinit() { unsafe { ctru_sys::psExit(); diff --git a/ctru-rs/src/services/reference.rs b/ctru-rs/src/services/reference.rs index 7fac227..41319a7 100644 --- a/ctru-rs/src/services/reference.rs +++ b/ctru-rs/src/services/reference.rs @@ -16,7 +16,9 @@ impl ServiceReference { S: FnOnce() -> crate::Result<()>, E: Fn() + Send + Sync + 'static, { - let mut value = counter.lock().expect("Mutex Counter for ServiceReference is poisoned"); // todo: handle poisoning + let mut value = counter + .lock() + .expect("Mutex Counter for ServiceReference is poisoned"); // todo: handle poisoning if *value == 0 { start()?; @@ -35,7 +37,10 @@ impl ServiceReference { impl Drop for ServiceReference { fn drop(&mut self) { - let mut value = self.counter.lock().expect("Mutex Counter for ServiceReference is poisoned"); // todo: handle poisoning + let mut value = self + .counter + .lock() + .expect("Mutex Counter for ServiceReference is poisoned"); // todo: handle poisoning *value -= 1; if *value == 0 { (self.close)(); diff --git a/ctru-sys/src/bin/docstring-to-rustdoc.rs b/ctru-sys/src/bin/docstring-to-rustdoc.rs index b7c7cb9..a843a1b 100644 --- a/ctru-sys/src/bin/docstring-to-rustdoc.rs +++ b/ctru-sys/src/bin/docstring-to-rustdoc.rs @@ -19,8 +19,8 @@ //! The followings are _partially_ transformed to Rustdoc format: //! * `@param` -use std::{env, fs, io}; use std::path::Path; +use std::{env, fs, io}; fn main() -> io::Result<()> { let args: Vec = env::args().collect(); @@ -33,8 +33,7 @@ fn main() -> io::Result<()> { .map(|v| { // Only modify lines with the following structure: `` #[doc ... ] `` if v.trim_start().starts_with("#[doc") && v.trim_end().ends_with("]") { - v - .replace("@brief", "") + v.replace("@brief", "") // Example: ``@param offset Offset of the RomFS...`` -> ``- offset Offset of the RomFS...`` // Will improve in the future .replace("@param", "* ") @@ -54,9 +53,7 @@ fn main() -> io::Result<()> { String::from(v) } }) - .map(|v| { - v + "\n" - }) + .map(|v| v + "\n") .collect::(); let old_bindings_path = bindings_path.to_str().unwrap().to_owned() + ".old"; @@ -67,4 +64,4 @@ fn main() -> io::Result<()> { fs::remove_file(&old_bindings_path)?; Ok(()) -} \ No newline at end of file +}