2 releases
0.1.1 | Nov 5, 2023 |
---|---|
0.1.0 | Nov 5, 2023 |
#1932 in Data structures
50KB
1K
SLoC
composite_types
Introducing type definitions in the style of Typescript to Rust!
use proc_macro_def::{compose_type};
struct FieldType {}
mod module {
compose_type! {
struct Example {
field: Option<FieldType>
}
struct MyStruct = Required(Example);
struct MyStruct2 = Optional(MyStruct);
pub struct MyStruct3 = Required(MyStruct);
}
const EXAMPLE: MyStruct = MyStruct2 {
field: None
};
}
struct Example2 {
field: Option<MyStruct3>
}
Usage
- Use the
compose_type!
macro - Import and define any types outside
compose_type!
as you normally would - You can reference these types within
compose_type!
, but cannot compose with them - Define structs within
compose_type!
to be used to compose new types - Reference your new types outside of
compose_type!
and use them in your project
Dependencies
~3.5–10MB
~109K SLoC