Dismantler
is a procedural macro that is used for disassembling structs
and fns
into their inner type
components that are then accompanied with documentation and examples. The Dismantler
structures will be wrapped into a module and reassigned with a name (default core
), this also goes for the static
and generic
fields.
toml
[dependencies]
dismantler = "0.0.1"
```rust use dismantler::dismantle;
struct Containter
struct Area(i32);
- Will let you access the struct types as followed:
rust
let current: Container::current = 10;
let buffer: Container::buffer = vec![current];
let another:
- It's also possible to use it as following:
rust
trait Trait: Container::protocol {
fn retrieve(&self) -> Container::protocol::buffer;
fn extend(&mut self, val: Container::protocol::another);
}
```
```rust use dismantler::dismantle;
struct Container
struct Tuple(i32, i32);
struct Tuple2
fn main() {
let a: Container::fields::a = 10;
let b: Container::b = vec![a];
let c: Container::c
assert!(container.a == a);
} ```
static
and generic
typesstatic
and generic
types```rust
struct #name { #(#ident: #ty)* }
// Turns into
// Docs (/w examples) describing the original item
and also what types
are available to use.
pub mod #name { #![allow(noncamelcase_types)]
// The static fields of the `item` as type aliases.
#(#ty_decls)* // Access through `#name::#field`
// A trait where all `ìtem` fields are associated types
#struct_generic // Access through `#name::gen`
// Docs (/w examples) describing the original `item`.
#[doc = #docs]
// The original `ìtem`.
#struct_original // Access through `#name::core`
} ```
```rust use dismantler::dismantle;
struct Containter
fn main() {
let x: Container
let y: MContainer::core<i32> = x;
} ```