Automatical formatting

This commit is contained in:
PlexSheep 2024-01-10 20:38:30 +00:00 committed by github-actions[bot]
parent 18fcdc6e59
commit 8f237ea40e
4 changed files with 14 additions and 15 deletions

View File

@ -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");
}

View File

@ -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}");
}

View File

@ -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",

View File

@ -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`
");
"
);
}