Crates.io | js_typify_gostruct |
lib.rs | js_typify_gostruct |
version | 2.1.1 |
source | src |
created_at | 2020-06-11 15:44:36.269273 |
updated_at | 2021-06-15 11:35:38.704958 |
description | A rust tool meant to convert a golang struct to a js type object. |
homepage | |
repository | https://github.com/Tevinthuku/js_typify_gostruct/ |
max_upload_size | |
id | 252834 |
size | 38,217 |
A rust tool meant to convert a golang struct to a js type object.
Based on the new re-write the name of this library might change, Its now possible to have interpreters for all sorts of languages, not just Javascript based Languages.
use js_typify_gostruct::Source;
fn main() -> Result<(), Vec<String>> {
let example = r#"
type Region struct {
Country string `json:"country"`
State string `json:"state"`
}
"#;
// converts to flow
let source = Source::new(example);
let result = source.transform_to("flow")?;
println!("{}", result);
// result will be
// // @flow
//export type Region = {country : string, state : string, }
// converts to typescript
let result = source.transform_to("typescript")?;
println!("{}", result);
// result will be
//export interface Region = {country : string, state : string, }
Ok(())
}
The examples folder contains various examples of how the library works & is to be used.
To run a specific example run the following command
eg
cargo run --example flow
cargo run --example typescript
TODO