From 8f237ea40e0cab06bb89dacb76864d7e92c3aefe Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Wed, 10 Jan 2024 20:38:30 +0000 Subject: [PATCH] Automatical formatting --- members/c-bindings/src/build.rs | 4 +--- members/c-bindings/src/main.rs | 12 +++++------- members/what-is/src/main.rs | 8 +++++--- src/main.rs | 5 +++-- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/members/c-bindings/src/build.rs b/members/c-bindings/src/build.rs index 04d6c3a..2f889c0 100644 --- a/members/c-bindings/src/build.rs +++ b/members/c-bindings/src/build.rs @@ -5,7 +5,5 @@ fn main() { // Tell Cargo that if the given file changes, to rerun this build script. println!("cargo:rerun-if-changed=src/hello.c"); - cc::Build::new() - .file("lib/test.c") - .compile("test"); + cc::Build::new().file("lib/test.c").compile("test"); } diff --git a/members/c-bindings/src/main.rs b/members/c-bindings/src/main.rs index 50c9968..7ef32a8 100644 --- a/members/c-bindings/src/main.rs +++ b/members/c-bindings/src/main.rs @@ -23,20 +23,18 @@ fn main() { // confirmed safe inputs let qux = unsafe { ret19() }; println!("`ret19()` returned {qux}"); - let st = MyStruct { - foo: 17, bar: 0x41 - }; + let st = MyStruct { foo: 17, bar: 0x41 }; // converting a c "string" to a real rust String is // a bit complicated let info: &str = unsafe { // convert the returned value to a rust internal CStr. std::ffi::CStr::from_ptr( // the function returns a pointer to a array of chars on the heap - structInfo(&st) + structInfo(&st), ) - // now to a string slice (result) - .to_str() - .unwrap() + // now to a string slice (result) + .to_str() + .unwrap() }; println!("{info}"); } diff --git a/members/what-is/src/main.rs b/members/what-is/src/main.rs index 3f1f467..1cb2418 100644 --- a/members/what-is/src/main.rs +++ b/members/what-is/src/main.rs @@ -1,4 +1,4 @@ -use std::any::{TypeId, type_name}; +use std::any::{type_name, TypeId}; //* # See what's behind the primitive datatypes of Rust //* //* This Crate shows off, how primitive Types of rust are stored in memory. @@ -26,8 +26,10 @@ macro_rules! investigate { unsafe { for (index, item) in $v.iter().enumerate() { let pointer = item as *const $t; - let raw_pointer: [u8; std::mem::size_of::<$t>()] = std::mem::transmute(item.clone()); - println!("\t{index:02x}\titem:\t{item:?}\n\ + let raw_pointer: [u8; std::mem::size_of::<$t>()] = + std::mem::transmute(item.clone()); + println!( + "\t{index:02x}\titem:\t{item:?}\n\ \t\tpointer: {:X?}\n\ \t\talign: {:#X} B\n\ \t\tmemory: {:X?}\n", diff --git a/src/main.rs b/src/main.rs index 63865b3..3aae6aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ fn main() { println!( -"The dark power of unsafe rust awakens! + "The dark power of unsafe rust awakens! This is the default executable! It does not do much, use another executable. @@ -9,5 +9,6 @@ Select your target like this: To see a list of all runnable binaries, you can use the following command. `cargo run --bin` -"); +" + ); }