google / moveit

Apache License 2.0
166 stars 18 forks source link

Add a moveit::strukt! macro for in-place struct construction #36

Open mcy opened 1 year ago

mcy commented 1 year ago

Currently, if you have a struct with at least one field of a type that can only be constructed via New, it can't be constructed without some pain. This new macro makes it possible to avoid that by taking a set of constructors and initializing the struct's fields one by one.

Tuple structs and type inference on the struct type are not well-supported. It is also not possible for one field of a struct initializer to refer to a previous one (for easy creation of self-pointing structs). Such enhancements will likely require a proc macro.