summaryrefslogtreecommitdiff
path: root/src/idl_gen_rust.cpp
diff options
context:
space:
mode:
authorVladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com>2020-09-21 23:31:27 +0700
committerGitHub <noreply@github.com>2020-09-21 09:31:27 -0700
commitfb4e1c34f995d50f03c8c306b602e20b73884810 (patch)
tree97b625c4f1cea1b2a5908bbb59fa193dd5878ef8 /src/idl_gen_rust.cpp
parent8c67b5b129f445c6bf5dbcbf2a18fec4c6334f16 (diff)
downloadflatbuffers-fb4e1c34f995d50f03c8c306b602e20b73884810.tar.gz
flatbuffers-fb4e1c34f995d50f03c8c306b602e20b73884810.tar.bz2
flatbuffers-fb4e1c34f995d50f03c8c306b602e20b73884810.zip
Add CharToLower and CharToUpper into util.s (#6126)
This commit adds replacement of `::tolower` and `::toupper`. Added CharToLower and CharToUpper routines reduce the number of cast operators that required for correct usage of standard C/C++ `::tolower/toupper` routines.
Diffstat (limited to 'src/idl_gen_rust.cpp')
-rw-r--r--src/idl_gen_rust.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp
index 62172d0b..90cb5718 100644
--- a/src/idl_gen_rust.cpp
+++ b/src/idl_gen_rust.cpp
@@ -29,14 +29,14 @@ std::string MakeSnakeCase(const std::string &in) {
std::string s;
for (size_t i = 0; i < in.length(); i++) {
if (i == 0) {
- s += static_cast<char>(tolower(in[0]));
+ s += CharToLower(in[0]);
} else if (in[i] == '_') {
s += '_';
} else if (!islower(in[i])) {
// Prevent duplicate underscores for Upper_Snake_Case strings
// and UPPERCASE strings.
if (islower(in[i - 1])) { s += '_'; }
- s += static_cast<char>(tolower(in[i]));
+ s += CharToLower(in[i]);
} else {
s += in[i];
}
@@ -48,7 +48,7 @@ std::string MakeSnakeCase(const std::string &in) {
std::string MakeUpper(const std::string &in) {
std::string s;
for (size_t i = 0; i < in.length(); i++) {
- s += static_cast<char>(toupper(in[i]));
+ s += CharToUpper(in[i]);
}
return s;
}