Browse Source

Fix formatting

pull/68/head
Andrea Ciliberti 2 years ago
parent
commit
fb38d8202f
  1. 2
      ctru-rs/examples/network-sockets.rs
  2. 17
      ctru-rs/examples/system-configuration.rs
  3. 2
      ctru-rs/src/lib.rs
  4. 9
      ctru-rs/src/services/reference.rs
  5. 9
      ctru-sys/src/bin/docstring-to-rustdoc.rs

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

@ -43,7 +43,7 @@ fn main() { @@ -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\n<html><body>Hello world</body></html>\r\n";

17
ctru-rs/examples/system-configuration.rs

@ -1,8 +1,8 @@ @@ -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() { @@ -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() {

2
ctru-rs/src/lib.rs

@ -4,8 +4,6 @@ @@ -4,8 +4,6 @@
#![feature(custom_test_frameworks)]
#![test_runner(test_runner::run)]
// Test PR
extern "C" fn services_deinit() {
unsafe {
ctru_sys::psExit();

9
ctru-rs/src/services/reference.rs

@ -16,7 +16,9 @@ impl ServiceReference { @@ -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 { @@ -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)();

9
ctru-sys/src/bin/docstring-to-rustdoc.rs

@ -19,8 +19,8 @@ @@ -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<String> = env::args().collect();
@ -33,8 +33,7 @@ fn main() -> io::Result<()> { @@ -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<()> { @@ -54,9 +53,7 @@ fn main() -> io::Result<()> {
String::from(v)
}
})
.map(|v| {
v + "\n"
})
.map(|v| v + "\n")
.collect::<String>();
let old_bindings_path = bindings_path.to_str().unwrap().to_owned() + ".old";

Loading…
Cancel
Save