* `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`
Looking at generated assembly, it turns out the optimizer is not smart
enough to get rid of the loop - use `copyMem` instead.
At least the compiler is smart enough to constant-propagate runtime
endian direction, resolving the review comment.
Also clarify why a minimum length is enfored - it could perhaps be
revisited, but that would leave a slightly odd API.
the `array` overloads are actually unnecessary with an optimizing
compiler - as long as it can prove the length, any extra checks will go
away on their own
also add `initCopyFrom`
* document optimizations
This definition is more robust. The previously existing version was
producing compilation errors in certain generic contexts. static
"regular" params are recommended in general as they are more flexible
than the explicit generic parameters.
* Optimized and exception-less encoding/decoding procedures for decimal integers.
* Add tests.
* Fix import path.
* Fix review comments.
* Code simplification.
* Make toBytes() allocation free.
* Do not perform conversion to signed type to avoid compiler's overflow checks.
Leb128 is a variable-length encoding for unsigned integers that is used
in a number of contexts - in particular, wasm, dwarf and protobuf.
This is an optimized low-level implementation that unrolls the loop
reading/writing the buffer - it is suitable to use as base for a more
specific API - no memory allocations, no exceptions.
This PR also fixes bitops2 to not raise on certaing uint->int
conversions, adapting bitops to nim 1.0 conversion rules by using a cast
instead of raising on uint->int conversion
* random helpers
* arrayops as a home for small array/openArray utilities
* assign2 - a replacement for genericAssign and assignment operators in
general which in nim are very slow
* use assign2 in a few places to speed things up
* fixes
* fixes