rust-or / rust-lp-modeler

Lp modeler written in Rust
MIT License
96 stars 29 forks source link

add ToTokens implementations for quoting Lp structs #43

Closed dginev closed 4 years ago

dginev commented 4 years ago

Hi! I have a bit of an auxiliary PR here.

I am working on a syntax extension crate which translates a declarative language into Rust code. A part of that language is declaring constraints on individual items, which get accumulated together into an LP problem, based on which parts of the syntax was used.

Long-story short, I would like the ability to quote!() all structs in the lp-modeler crate, so that I can automatically generate rust sources with LP logic in them. This PR takes a first stab at that, and I am not a fan of the intrusive new dependencies -- but still not sure if there is a better practice, e.g. hiding behind a feature flag. What I think I know is that ToTokens implementations belong in the crate defining the struct, hence the PR here.

Still testing with my local project, will add a couple of more comments later this week.

jcavat commented 4 years ago

Hello. Sounds interesting ! Maybe you should put the ToTokens logic into a different modules later.