- 
                Notifications
    
You must be signed in to change notification settings  - Fork 98
 
Open
Description
I'm experimenting with code generation based on schemas generated by the glaze C++ library.
The following C++ struct
struct my_struct {
  int i{};
  double d{};
  std::string hello{};
  std::array<uint64_t, 3> arr{};
  std::map<std::string, int> map{};
};yields this schema:
And this is the generated rust code.
I was wondering the following:
- Apparently, there is no rust equivalent of 
my_structbeing generated. Instead just for every type insidemy_struct. Is there maybe an issue with the schema? - Is it somehow possible to prevent generating wrapper types for types like 
Doubleetc and just use equivalent types directly? 
To demonstrate the latter: I pasted the schema to quicktype and the result seems quite idiomatic:
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MyStruct {
    arr: Option<Vec<i64>>,
    d: Option<f64>,
    hello: Option<String>,
    i: Option<i64>,
    map: Option<HashMap<String, i64>>,
}(note: one can get rid of generating all the values as Option by adding "required": ["arr", "d", "hello", "i", "map"], )
Metadata
Metadata
Assignees
Labels
No labels