Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upRequest: macros for making `NewPost` and `Post` structs less redundant #919
Comments
This comment has been minimized.
|
Come to think of it, this is not really core to diesel's mission. It's probably better as an external library. It might need to know about diesel's Insertable, etc. derivations, but otherwise would probably be best as a separate library. |
rbalicki2
closed this
May 21, 2017
This comment has been minimized.
|
Have a look at #860 too ^^ |
This comment has been minimized.
behos
commented
Nov 10, 2017
|
I've created something along these lines for the new structure here https://github.com/behos/models-derive Used like https://github.com/behos/models-derive/blob/master/tests/default_insertable.rs#L20 but i haven't published this as a crate since I'm not 100% sure it's complete. I'd be happy to get some feedback and ideas/contributions around that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rbalicki2 commentedMay 20, 2017
•
edited
Would it be possible for diesel to provide macros so that if I have two models, say
PostandNewPost, which differ only in thatPostalso has anidfield, I could define them using only a single struct?e.g.
And now, there is a
NewPoststruct as well.I've thought about doing this with traits, but it ends up being very redundant and OOP in a java-like way. Macros could probably help, though.
This is far above my pay grade right now, but I wanted to make this request - perhaps it already exists or is in the pipeline :)