jamiebrynes7 / spatialos-sdk-rs

Rust integration of the SpatialOS C API bindings
Apache License 2.0
21 stars 6 forks source link

Add constructors for generated types. #86

Open jamiebrynes7 opened 5 years ago

jamiebrynes7 commented 5 years ago

Currently, the only way to create generated types is to use the object initializer syntax (or at least that's what its called in C#). Instead, we should provide a constructor as well to cut down the verbosity.

Currently we have:

improbable::Coordinates { 
    x: 0.0, 
    y: 0.0, 
    z: 0.0 
}

where we could have:

improbable::Coordinates::new(0.0, 0.0, 0.0)
randomPoison commented 5 years ago

There's a nifty crate for making this easy to do, would allow us to write less code generation on our end: https://github.com/nrc/derive-new

jamiebrynes7 commented 5 years ago

Hmmm - I wonder if its worth pulling in (and likely re-exporting) a dependency when it should be fairly trivial codegen to write?