Skip to content

Commit

Permalink
Prepare code for breaking change in Protobuf C++ API.
Browse files Browse the repository at this point in the history
Protobuf 6.30.0 will change the return types of Descriptor::name() and other
methods to absl::string_view. This makes the code work both before and after
such a change.

PiperOrigin-RevId: 713643887
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jan 9, 2025
1 parent b0b7bf3 commit 0d4842d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/google/protobuf/compiler/rust/naming.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ std::string GetCrateName(Context& ctx, const FileDescriptor& dep) {

std::string GetEntryPointRsFilePath(Context& ctx, const FileDescriptor& file) {
size_t last_slash = file.name().find_last_of('/');
std::string dir = last_slash == std::string::npos
? ""
: file.name().substr(0, last_slash + 1);
return absl::StrCat(dir, ctx.opts().generated_entry_point_rs_file_name);
return absl::StrCat(last_slash == std::string::npos
? ""
: file.name().substr(0, last_slash + 1),
ctx.opts().generated_entry_point_rs_file_name);
}

std::string GetRsFile(Context& ctx, const FileDescriptor& file) {
Expand Down

0 comments on commit 0d4842d

Please sign in to comment.