spatialos-sdk-rs icon indicating copy to clipboard operation
spatialos-sdk-rs copied to clipboard

Add constructors for generated types.

Open jamiebrynes7 opened this issue 6 years ago • 2 comments

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)

jamiebrynes7 avatar Mar 21 '19 11:03 jamiebrynes7

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

randomPoison avatar Mar 22 '19 00:03 randomPoison

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

jamiebrynes7 avatar Mar 24 '19 11:03 jamiebrynes7