Tags: tock/libtock-rs
Tags
Merge #370 370: Add a simple way to convert a CommandReturn into a Result r=jrvanwhy a=kupiakos There are a few changes that this makes: - `CommandReturn` is `#[must_use]` - `ErrorCode` includes `BadRVal` - `CommandReturn` has a `to_result` method I experimented with a few methods of structuring `to_result` to have the smallest overhead per monomorphization. What you see here is the best I could do. I also tried: - Providing a `try_to_result` and using that (lots of overhead) - Preserving the error code of the failure variant on `BADRVAL` - Associated constant `FailureData::BADRVAL` - Associated fn `FailureData::from_wrong_variant(r1: ErrorCode) -> Self` - A helper function `fn to_result_helper(self, success_variant: ReturnVariant, error_variant: ReturnVariant) -> (bool, u32, u32, u32)` that would do the branches and replacing `r1` with `BadRVal` and other registers with `0` in the case of the wrong variant. I thought this would reduce things further but it seemed to make it worse in my tests. Then again - I only had one instance of each monomorphization. Co-authored-by: Alyssa Haroldsen <[email protected]>