[promises] Fix LoopCtl<StatusOr<unique_ptr<T>>> (#34161)

pull/34075/head
Craig Tiller 1 year ago committed by GitHub
parent 0900584543
commit eaa5784d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/core/lib/promise/loop.h

@ -54,9 +54,9 @@ struct LoopTraits<absl::StatusOr<LoopCtl<T>>> {
using Result = absl::StatusOr<T>;
static LoopCtl<Result> ToLoopCtl(absl::StatusOr<LoopCtl<T>> value) {
if (!value.ok()) return value.status();
const auto& inner = *value;
auto& inner = *value;
if (absl::holds_alternative<Continue>(inner)) return Continue{};
return absl::get<T>(inner);
return absl::get<T>(std::move(inner));
}
};
@ -104,14 +104,14 @@ class Loop {
if (auto* p = promise_result.value_if_ready()) {
// - then if it's Continue, destroy the promise and recreate a new one
// from our factory.
auto lc = LoopTraits<PromiseResult>::ToLoopCtl(*p);
auto lc = LoopTraits<PromiseResult>::ToLoopCtl(std::move(*p));
if (absl::holds_alternative<Continue>(lc)) {
Destruct(&promise_);
Construct(&promise_, factory_.Make());
continue;
}
// - otherwise there's our result... return it out.
return absl::get<Result>(lc);
return absl::get<Result>(std::move(lc));
} else {
// Otherwise the inner promise was pending, so we are pending.
return Pending();

Loading…
Cancel
Save