Skip to content

Commit

Permalink
Use {} instead of () for PtrAndLen POD ctor.
Browse files Browse the repository at this point in the history
C++20 supports parenthesis in this position but older C++ only accepts curley braces.

PiperOrigin-RevId: 676547609
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Sep 19, 2024
1 parent 63f6262 commit 452d528
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void SingularCord::InThunkCc(Context& ctx, const FieldDescriptor& field) const {
::google::protobuf::rust::PtrAndLen $borrowed_getter_thunk$($QualifiedMsg$* msg) {
const absl::Cord& cord = msg->$field$();
absl::string_view s = cord.TryFlat().value();
return ::google::protobuf::rust::PtrAndLen(s.data(), s.size());
return ::google::protobuf::rust::PtrAndLen{s.data(), s.size()};
}
std::string* $owned_getter_thunk$($QualifiedMsg$* msg) {
const absl::Cord& cord = msg->$field$();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void SingularString::InThunkCc(Context& ctx,
R"cc(
::google::protobuf::rust::PtrAndLen $getter_thunk$($QualifiedMsg$* msg) {
absl::string_view val = msg->$field$();
return ::google::protobuf::rust::PtrAndLen(val.data(), val.size());
return ::google::protobuf::rust::PtrAndLen{val.data(), val.size()};
}
void $setter_thunk$($QualifiedMsg$* msg, std::string* s) {
msg->set_$field$(std::move(*s));
Expand Down
2 changes: 1 addition & 1 deletion src/google/protobuf/compiler/rust/naming.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ PROTOBUF_CONSTINIT const MapKeyType kMapKeyTypes[] = {
/*cc_ffi_key_t=*/"google::protobuf::rust::PtrAndLen",
/*cc_from_ffi_key_expr=*/
"std::string(key.ptr, key.len)", /*cc_to_ffi_key_expr=*/
"google::protobuf::rust::PtrAndLen(cpp_key.data(), cpp_key.size())"}};
"google::protobuf::rust::PtrAndLen{cpp_key.data(), cpp_key.size()}"}};

} // namespace rust
} // namespace compiler
Expand Down

0 comments on commit 452d528

Please sign in to comment.