Eric Mastro
096ca864b0
tuple binding and unpacking support ( #29 )
...
* tuple binding and unpacking support
* support tuple binding in nim < 1.6
* Use ? instead of Option[] in tests
* Test binding of optional tuple, not just tuple
* Add tests for tuple unpacking of Result
* Remove unused import
* Rearrange tuple binding code
Introduce separate proc for creation of unpacking
statement.
Use `quote do` to make code as similar as possible
to the `bindLet` and `bindVar` templates.
* Add tests for failed tuple bindings
---------
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
2023-02-14 09:56:32 +11:00
Mark Spanbroek
4d631b1ba9
Fix: ensure that options and results are only evaluated once
2022-09-28 11:36:28 +02:00
Mark Spanbroek
92641b552d
Switch warningAsError only works for Nim >= 1.4.0
2021-12-04 17:56:14 +01:00
Mark Spanbroek
cfe4c6fc95
Ensure that =? works with types that do not have a default value
2021-12-04 17:26:08 +01:00
Mark Spanbroek
93f5c919fb
Ensure that optional binding works with closures
2021-05-31 16:24:21 +02:00
Mark Spanbroek
2700038316
Fix use of =? in generic code
2021-05-06 17:12:52 +02:00
Mark Spanbroek
8bf4f27f30
Avoid wrapping option in option when using .?[] operator
2021-05-04 16:17:09 +02:00
Mark Spanbroek
e8ab268758
Ensure that .? chains work in generic code
2021-05-04 15:55:05 +02:00
Mark Spanbroek
0569625f6a
Replace .get with operator !
...
Rationale: when looking for code that might crash it's
easier to spot exclamation marks than invocations of get.
2021-04-19 15:52:07 +02:00
Mark Spanbroek
fa56587bcd
Avoid wrapping option in option and result in result
2021-04-17 19:50:02 +02:00
Mark Spanbroek
d82581244c
Simplify
2021-04-17 19:25:33 +02:00
Mark Spanbroek
a8834aea66
Add missing test from readme
2021-04-16 12:27:43 +02:00
Mark Spanbroek
ef5f796463
without statement
2021-04-16 12:27:17 +02:00
Mark Spanbroek
a2023ae18e
Documented how to work with =? in generic procs
2021-04-12 18:05:01 +02:00
Mark Spanbroek
3e92c35a85
Rename chaining and indexing operators
...
Chaining operator is now `.?`
Indexing operator is now `.?[]`
Reason: interoperability with the binding `=?` operator.
Chaining and indexing now have lower operator precedence
than binding, ensuring that expressions such as `if a =? b.?c`
work as expected.
2021-04-12 16:07:56 +02:00
Mark Spanbroek
40f5b4f1b8
Allow indexing of tables with ?[]
2021-03-18 17:58:48 +01:00
Mark Spanbroek
91f97c73ef
Evaluate =? expressions only once
2021-03-18 16:59:55 +01:00
Mark Spanbroek
aef59c42eb
Allow optional binding to vars
2021-03-18 09:50:06 +01:00
Mark Spanbroek
21927f3c88
Replace "check false" with "fail"
2021-03-13 11:54:03 +01:00
Mark Spanbroek
8683732d99
Chaining operator becomes ?. instead of .?
2021-03-11 17:50:30 +01:00
Mark Spanbroek
53924aeeda
Handle calls and operators following a .? chain
...
Fixes #3
2021-03-11 16:17:26 +01:00
Mark Spanbroek
c7fabfc23b
Add readme
2021-03-08 16:11:20 +01:00
Mark Spanbroek
1b47843012
Lift operators so that they can be used on options and results
2021-03-07 13:07:33 +01:00
Mark Spanbroek
81ed9b652c
Initial version of questionable
...
Syntactic sugar for std/options, pkg/result and pkg/stew
2021-03-06 10:38:44 +01:00