working bool dump
This commit is contained in:
parent
3cf32c5a2f
commit
8ec7bd2b38
|
@ -34,3 +34,7 @@ checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rs-unsafe"
|
name = "rs-unsafe"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "what-is"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
".",
|
".",
|
||||||
"members/c-bindings"
|
"members/c-bindings",
|
||||||
|
"members/what-is",
|
||||||
]
|
]
|
||||||
default-members = [
|
default-members = [
|
||||||
".",
|
".",
|
||||||
"members/c-bindings"
|
"members/c-bindings",
|
||||||
|
"members/what-is",
|
||||||
]
|
]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "what-is"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
|
@ -0,0 +1,42 @@
|
||||||
|
use std::any::{TypeId, type_name};
|
||||||
|
//* # See what's behind the primitive datatypes of Rust
|
||||||
|
//*
|
||||||
|
//* This Crate shows off, how primitive Types of rust are stored in memory.
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("bool");
|
||||||
|
let mut items = Vec::new();
|
||||||
|
items.push(true);
|
||||||
|
items.push(false);
|
||||||
|
unsafe {
|
||||||
|
for (index, item) in items.iter().enumerate() {
|
||||||
|
let mem_item: [u8; 1] = std::mem::transmute(*item);
|
||||||
|
let ref_item: [u8; 8] = std::mem::transmute(item);
|
||||||
|
println!("\t{index:02x}\titem:\t{item}\n\
|
||||||
|
\t\tmemory: {:X?}\n\n\
|
||||||
|
\t\tlocal ref: {:X?}",
|
||||||
|
mem_item,
|
||||||
|
ref_item,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dump_type<T: 'static>() {
|
||||||
|
println!("{:?}", TypeId::of::<T>());
|
||||||
|
let mut items = Vec::new();
|
||||||
|
items.push(true);
|
||||||
|
items.push(false);
|
||||||
|
unsafe {
|
||||||
|
for (index, item) in items.iter().enumerate() {
|
||||||
|
let mem_item: [u8; 1] = std::mem::transmute(*item);
|
||||||
|
let ref_item: [u8; 8] = std::mem::transmute(item);
|
||||||
|
println!("\t{index:02x}\titem:\t{item}\n\
|
||||||
|
\t\tmemory: {:X?}\n\n\
|
||||||
|
\t\tlocal ref: {:X?}",
|
||||||
|
mem_item,
|
||||||
|
ref_item,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue