1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2024 Google LLC. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #ifndef GOOGLE_PROTOBUF_COMPILER_RUST_RUST_KEYWORDS_H__ 9 #define GOOGLE_PROTOBUF_COMPILER_RUST_RUST_KEYWORDS_H__ 10 11 #include "absl/strings/string_view.h" 12 13 namespace google { 14 namespace protobuf { 15 namespace compiler { 16 namespace rust { 17 18 // Returns true if the provided name is legal to use as a raw identifier name 19 // by prefixing with r# 20 // https://doc.rust-lang.org/reference/identifiers.html#raw-identifiers 21 bool IsLegalRawIdentifierName(absl::string_view str_without_r_prefix); 22 23 // Returns true if the provided str is a Rust 2021 Edition keyword and cannot be 24 // used as an identifier. These symbols can be used with an r# prefix unless 25 // IsLegalRawIdentifierName returns false. This function should always match the 26 // behavior for the corresponding Edition that our emitted crates use. 27 bool IsRustKeyword(absl::string_view str); 28 29 } // namespace rust 30 } // namespace compiler 31 } // namespace protobuf 32 } // namespace google 33 34 #endif // GOOGLE_PROTOBUF_COMPILER_RUST_RUST_KEYWORDS_H__ 35