[roll pigweed] pw_result: Add and_then monadic operation

This CL adds a monadic operation to pw::Result<T> for `and_then`. 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 chaining multiple operations
that might fail.

  Result<std::string> GetIntegerString();
  Result<int> ConvertStringToInteger(const std::string&);

  Result<int> x = GetIntegerString()
                    .and_then(ConvertStringToInteger)
                    .and_then([](int i) { return Result<int>(i * 2) });

Original-Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/100802

https://pigweed.googlesource.com/pigweed/pigweed
pigweed Rolled-Commits: 6e3bc74cc4b71c0..940a29382017e8c
Roller-URL: https://ci.chromium.org/b/8806182317674255089
Cq-Cl-Tag: roller-builder:pigweed-zephyr-roller
Cq-Cl-Tag: roller-bid:8806182317674255089
CQ-Do-Not-Cancel-Tryjobs: true
Change-Id: I8f97812b46068e6896a35aeecf358c19f4862309
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/zephyr-integration/+/105786
Bot-Commit: Pigweed Integration Roller <pigweed-integration-roller@pigweed.google.com.iam.gserviceaccount.com>
Commit-Queue: Pigweed Integration Roller <pigweed-integration-roller@pigweed.google.com.iam.gserviceaccount.com>
1 file changed
tree: 7d6ece6fd91e85e3901182b61fbd84ea722a45bb
  1. .gitmodules
  2. test.sh