Change iterators to return Result #648
… pair The method is morally equivalent to calling `key` and `value` methods separately however it reduces number of times validity of the iterator needs to be checked. Since that check goes through ffi layer and calls a virtual method it doesn’t optimise well. Therefore, reducing number of times the `valid` method is called optimises the code a wee bit.
Firstly, introduce helper assertions which reduce code repetition. They do it by encapsulating verifying output of the iterator into a single location. This will be useful in upcoming commit which changes the Item type of the iterator. Secondly, keep keys and values declared at the start of some of the tests as slices without boxing them. Doing the latter introduces conveluted syntax such as `&*k1`; keeping them as slices simplifies the syntax and also allows them to be converte into constsants. Lastly, replace `cba` helper methods with `pair` which construct a pair of boxed slices. This removes some repetition since after the previous point `cba` was only ever used in a pair.
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.