View is Copy, and so it can preserve the lifetime of itself when accessing any fields. PiperOrigin-RevId: 599323122pull/15470/head
parent
fe6a601598
commit
ab8b762941
11 changed files with 115 additions and 14 deletions
@ -0,0 +1,35 @@ |
||||
#include "google/protobuf/compiler/rust/accessors/accessor_case.h" |
||||
|
||||
#include "absl/strings/string_view.h" |
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
namespace compiler { |
||||
namespace rust { |
||||
|
||||
absl::string_view ViewReceiver(AccessorCase accessor_case) { |
||||
switch (accessor_case) { |
||||
case AccessorCase::VIEW: |
||||
return "self"; |
||||
case AccessorCase::OWNED: |
||||
case AccessorCase::MUT: |
||||
return "&self"; |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
absl::string_view ViewLifetime(AccessorCase accessor_case) { |
||||
switch (accessor_case) { |
||||
case AccessorCase::VIEW: |
||||
return "'msg"; |
||||
case AccessorCase::OWNED: |
||||
case AccessorCase::MUT: |
||||
return "'_"; |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
} // namespace rust
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
Loading…
Reference in new issue