Crates.io | ronky |
lib.rs | ronky |
version | |
source | src |
created_at | 2024-07-11 19:27:56.666506 |
updated_at | 2024-12-02 16:39:51.964039 |
description | Export a part of the Rust AST to JSON |
homepage | |
repository | https://github.com/Arthurdw/ronky |
max_upload_size | |
id | 1299928 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
There is still a lot of work to be done, but here is a simple example of what I have in mind.
The following code and it's output:
#[derive(Export)]
struct Human {
name: String,
age: u32,
friends: Vec<Human>,
pets: Vec<Pet>,
}
#[derive(Export)]
struct Pet {
name: String,
species: String,
}
Which results in the following JSON:
{
"types": [
{
"name": "Human",
"fields": [
{
"name": "name",
"type": "String"
},
{
"name": "age",
"type": "u32"
},
{
"name": "friends",
"type": "list"
"of": ["Human"],
},
{
"name": "pets",
"type": "list"
"of": ["Pet"],
}
]
},
{
"name": "Pet",
"fields": [
{
"name": "name",
"type": "String"
},
{
"name": "species",
"type": "String"
}
]
}
]
}
That can then be converted to the following typescript (any supported language, or create your own):
interface Human {
name: string;
age: number;
friends: Human[];
pets: Pet[];
}
interface Pet {
name: string;
species: string;
}
In loving memory of my dear cat Ronky, named for his unique habit of spinning with a loud sound (to "ronk" in Dutch). Ronky lived to the age of 14 and bravely endured acromegaly. This condition resulted in the abnormal growth of his tissues and bones.
He passed away peacefully, surrounded by those who loved him. He will be deeply missed.
Photo by Startshot