New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved usablity of DictionaryList with dynamic types #1745

Merged
merged 3 commits into from Apr 26, 2017

Conversation

Projects
None yet
2 participants
@thaven
Contributor

thaven commented Apr 23, 2017

The recently added HTTPServerRequest.context is a DictionaryList!Variant. That turns out quite cumbersome to work with. This pull request adds templated overloads for DictionaryList's methods get, opIndexAssign and addField to get things to work intuitively.

thaven added some commits Apr 23, 2017

Improve usability of DictionaryList with dynamic types
I found it quite cumbersome to work with HTTPServerRequest.context because any value to be assigned to a context key needs to be casted and getting a value required writing something like `req.context.get("foo").get!string`. Using the templated getter, no cast is needed to assign a value and getting it goes like `req.context.get!string("foo")`.
Work around DMD bug
Nasty bug... I tried to find a reduced testcase, but could not get it to fail like here.
@s-ludwig

Makes sense, directly using Variant + a dictionary is indeed a little verbose. At first I thought that it would be cleaner to derive a separate dictionary type with the advanced API, but upon further inspection I couldn't find a compelling reason not to integrate it directly.

I just want to fix master to pass the Travis-CI checks before merging this.

@s-ludwig s-ludwig merged commit 8e84170 into vibe-d:master Apr 26, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment