Support domain specific variable type #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Variable
in favor of tools for writing your own domain specific variable typesArc
,Rc
andRefCell
in favor ofOrderedFloat
andOption
-Solver
can now safely be passed between threads withSend
andSync
Solver::optimise
and removesSolver.artificial
as its no longer neededThis provides library users with the ability to specify their own variables. All the structs associated with constructing constraint syntax now take a type variable that represents the domain specific variable type.
Variable
itself is removed as its trivial to derive it. The tests provide an example. There's a new modulederive_syntax
for automatically deriving the necessary machinery to write constraints and expressions using the domain specific variable type.This has two good effects:
HashMap<MyType, Variable>
mapping from meaning to cassowary variable.n
separate solvers - one for each dimension - and not have the types mix. For example:^ Here you can't mix constraints from the two axes without triggering a compile time error, which I think I like. Anyway - there's only a couple tests really, so YMMV.
This is currently a draft PR until I update the documentation.