Automatical formatting
This commit is contained in:
parent
18fcdc6e59
commit
8f237ea40e
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -23,16 +23,14 @@ 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()
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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`
|
||||
");
|
||||
"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue