commit | b20a351802f04d6fb9946b0ce3b668e309990bdc | [log] [tgz] |
---|---|---|
author | RJ Ascani <rjascani@pigweed.infra.roller.google.com> | Wed Aug 10 22:54:05 2022 +0000 |
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed Aug 10 22:54:05 2022 +0000 |
tree | 3417305887b68e0dccb5de710fd93532d971b10c | |
parent | 661e8f2e052429376f2c400a6239d0d2cf5caebe [diff] |
[roll pigweed] pw_result: Add transform monadic operation This CL adds a monadic operation to pw::Result<T> for `transform`. This method takes a function, which will be invoked only if the pw::Result<T> contains a value. If the pw::Result<T> contains a status, then that status will be returned. This is useful for applying a function to a Result and transforming the type. Result<int> ConvertStringToInteger(std::string_view); int MultiplyByTwo(int x) { return x * 2; } Result<int> x = ConvertStringToInteger("42") .transform(MultiplyByTwo); Original-Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/101348 https://pigweed.googlesource.com/pigweed/pigweed pigweed Rolled-Commits: 9b7743e6e8faa10..b568966d401b1b3 Roller-URL: https://ci.chromium.org/b/8806177444648253713 Cq-Cl-Tag: roller-builder:pigweed-zephyr-roller Cq-Cl-Tag: roller-bid:8806177444648253713 CQ-Do-Not-Cancel-Tryjobs: true Change-Id: Idb356b49c135d7fe5660c6c4135a0752bc6ffcc5 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/zephyr-integration/+/105754 Commit-Queue: Pigweed Integration Roller <pigweed-integration-roller@pigweed.google.com.iam.gserviceaccount.com> Bot-Commit: Pigweed Integration Roller <pigweed-integration-roller@pigweed.google.com.iam.gserviceaccount.com>