Allow `IsOkAndHolds` to rely on duck typing for matching `StatusOr` like types instead of uniquely `absl::StatusOr`, e.g. `google::cloud::StatusOr`. This is intended to support existing types that provide compliant `.ok()` and `.status()`. However support for types other than absl::StatusOr is not a guaranteed feature and may be removed in the future PiperOrigin-RevId: 828072487 Change-Id: I1ae696b41eecf6048bd7a4ae3d893648e57e81d1
diff --git a/absl/status/internal/status_matchers.h b/absl/status/internal/status_matchers.h index 0750622..d11742b 100644 --- a/absl/status/internal/status_matchers.h +++ b/absl/status/internal/status_matchers.h
@@ -69,8 +69,8 @@ bool MatchAndExplain( StatusOrType actual_value, ::testing::MatchResultListener* result_listener) const override { - if (!GetStatus(actual_value).ok()) { - *result_listener << "which has status " << GetStatus(actual_value); + if (!actual_value.ok()) { + *result_listener << "which has status " << actual_value.status(); return false; }