14 Commits

Author SHA1 Message Date
Jacek Sieka
9d0f1167ca
results: [] for void (#103)
mostly for consistency.. but it's used in nim-eth tests
2022-01-13 22:02:44 +01:00
Jacek Sieka
6ad35b876f result: expose value/error in errorOr/valueOr
* fix error type as well
2022-01-11 16:39:12 +02:00
Jacek Sieka
d2ae2889e8
Result refresh (#96)
* `Result` refresh

* add full support for `Result[T, void]` (aka `Opt[T]` aka `Option[T]`)
* expand tests
* add `flatten`, `filter` of `Option` fame
* add `tryError` that raises a regular exception when result holds a
value
* fix `$` to print `ok`/`err` in lower-case, like the functions that
created the result
* add `orErr` that collapses all errors to a single value of a
potentially different type - useful when translating errors between
layers
* `capture` should work with `CatchableError`
* remove `Defect`-dependent tests

* Update stew/results.nim

* avoid redundant error message when converting error to string
* avoid multiple evaluation in `valueOr`
* add `unsafeError` to match `unsafeGet`
* let `valueOr` evaluate a block
* add `errorOr` to mirror `valueOr`
2022-01-10 00:22:09 +02:00
Jacek Sieka
3c91b8694e
add void tests (#84) 2021-07-07 10:12:20 +02:00
Mamy Ratsimbazafy
6d3e6a21ca
results.== with void, Reboot #73 addressing comments (#74) 2021-01-26 15:06:17 +01:00
Mamy Ratsimbazafy
b4b3841a85
Revert "Allow comparing Result[void, E] (#71)" (#73)
This reverts commit 068412ff4e01dcb03c73bc8b7e9805fe71c5f010.
2021-01-26 14:20:09 +01:00
Mamy Ratsimbazafy
068412ff4e
Allow comparing Result[void, E] (#71) 2021-01-26 14:12:08 +01:00
Jacek Sieka
e15c1ae012
results: prevent dangling cstring pointers in result (#63) 2020-12-09 17:21:12 +01:00
Jacek Sieka
ec2f52b0ce
results: make ? work with void (#50) 2020-07-13 18:09:45 +02:00
Jacek Sieka
f125f6e8d1 space 2020-05-08 18:54:36 +03:00
Jacek Sieka
2d9226464d heterogenous or
Useful for translating `error` results
2020-05-08 18:54:36 +03:00
Jacek Sieka
ff755bbf75
change get/[] to always raise Defect and tryGet to do eh bridge mode (#30)
* also sprinkle mixin randomly across the codebase
2020-04-16 18:23:12 +02:00
Jacek Sieka
805ef4f1b2
result: cleanups
* fix defect raising without `$`
* doc updates
* better `?` that doesn't cause raises effect (it should, because of
FieldError but...)
2020-04-11 16:22:37 +02:00
Jacek Sieka
b06a5b6e32
result -> results (#27) 2020-04-07 11:43:07 +02:00