Skip to content

Memory layout analysis tool for rust structs, enums and unions

License

Notifications You must be signed in to change notification settings

justanothercell/struct_scalpel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

struct_scalpel

Github crates.io License Stars Lines of code


Memory layout analysis tool for rust structs, enums, unions, tuples, and references, prints to console using ansi escape codes.

Simply derive Dissectible and call print_dissection_info to get a well formatted overview.

use struct_scalpel::{Dissectible, print_dissection_info};

#[derive(Dissectible)]
struct Person {
    name: String,
    age: u32,
    is_student: bool,
    height: f64,
    favorite_numbers: Vec<u8>,
}

fn main() {
    print_dissection_info::<Person>();
}

With dissect_std you can even disect some std items, with only a few type path deviations for private types.

  • String
  • Option
  • Result<T, E>
  • Box<T, A: Allocator>
  • Rc
  • cell
    • UnsafeCell
    • Cell
    • RefCell
    • OnceCell
  • sync
    • OnceLock

Disclaimer: This may not work in all cases, such as where some fields are unsized or dependant on a sys (os) implementation

This also works with generics and different layout strategies

About

Memory layout analysis tool for rust structs, enums and unions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages