Skip to content

Commit

Permalink
fix optional nullopt
Browse files Browse the repository at this point in the history
Signed-off-by: dentiny <[email protected]>
  • Loading branch information
dentiny committed Oct 8, 2024
1 parent f9ca13e commit e0fed71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ray/util/container_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ std::ostream &operator<<(std::ostream &os,

template <typename T>
std::ostream &operator<<(std::ostream &os, DebugStringWrapper<std::optional<T>> c) {
if (!c.obj_.has_value()) {
return os << "(nullopt)";
}
return os << debug_string(c.obj_.value());
}

Expand Down
1 change: 1 addition & 0 deletions src/ray/util/tests/container_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ TEST(ContainerUtilTest, TestDebugString) {

// Optional.
ASSERT_EQ(debug_string_to_string(std::nullopt), "(nullopt)");
ASSERT_EQ(debug_string_to_string(std::optional<std::string>{}), "(nullopt)");
ASSERT_EQ(debug_string_to_string(std::optional<std::string>{"hello"}), "hello");

// Composable: tuples of pairs of maps and vectors.
Expand Down

0 comments on commit e0fed71

Please sign in to comment.