-
Notifications
You must be signed in to change notification settings - Fork 0
Wrap recursive Rust types into Box #10
Copy link
Copy link
Closed
Labels
BugSomething isn't workingSomething isn't workingTarget: RustRust code generationRust code generation
Description
Recursive types like this one cause Rust to fail to compile:
Json: JsonNull | JsonBoolean | JsonNumber | JsonString | JsonArray | JsonObject | JsonUnion | JsonLiteral | JsonTuple
JsonBase: {
doc?: string
}
JsonNull: {
...JsonBase,
kind: "null"
}
JsonBoolean: {
...JsonBase,
kind: "boolean"
}
JsonNumber: {
...JsonBase,
kind: "number"
}
JsonString: {
...JsonBase,
kind: "string"
}
JsonArray: {
...JsonBase,
kind: "array",
descriptor: Json
}
JsonObject: {
...JsonBase,
kind: "object",
properties: [JsonProperty]
}
JsonProperty: {
...JsonBase,
kind: "property",
name: string,
descriptor: Json,
required: boolean
}
JsonUnion: {
...JsonBase,
kind: "union",
descriptors: [Json]
}
JsonTuple: {
...JsonBase,
kind: "tuple",
descriptors: [Json]
}
JsonLiteral: {
...JsonBase,
kind: "literal",
value: string | int | float | boolean
}
Using Box where appropriate solves it:
pub struct JsonArray {
pub doc: Option<String>,
pub kind: JsonArrayKindArray,
pub descriptor: Box<Json>,
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't workingTarget: RustRust code generationRust code generation
Projects
Status
Done