rust: Fixed MakeCamelCase (#4932) (#4936)

* Fixed MakeCamelCase behavior when supplied Upper_Camel_Case,
snake_case and UPPERCASE strings.
* Modified the rust integration test to reflect changes.
This commit is contained in:
jean-airoldie
2018-09-26 16:35:02 -04:00
committed by Robert
parent 49fed8c4f6
commit c56fff88a2
4 changed files with 18 additions and 12 deletions

View File

@@ -1110,7 +1110,7 @@ impl<'a> Monster<'a> {
#[inline]
#[allow(non_snake_case)]
pub fn test_as_my_game___example_2___monster(&'a self) -> Option<super::example_2::Monster> {
pub fn test_as_my_game_example_2_monster(&'a self) -> Option<super::example_2::Monster> {
if self.test_type() == Any::MyGame_Example2_Monster {
self.test().map(|u| super::example_2::Monster::init_from_table(u))
} else {

View File

@@ -34,8 +34,8 @@ pub enum EnumInNestedNS {
}
const ENUM_MIN_ENUM_IN_NESTED_N_S: i8 = 0;
const ENUM_MAX_ENUM_IN_NESTED_N_S: i8 = 2;
const ENUM_MIN_ENUM_IN_NESTED_NS: i8 = 0;
const ENUM_MAX_ENUM_IN_NESTED_NS: i8 = 2;
impl<'a> flatbuffers::Follow<'a> for EnumInNestedNS {
type Inner = Self;
@@ -69,22 +69,22 @@ impl flatbuffers::Push for EnumInNestedNS {
}
#[allow(non_camel_case_types)]
const ENUM_VALUES_ENUM_IN_NESTED_N_S:[EnumInNestedNS; 3] = [
const ENUM_VALUES_ENUM_IN_NESTED_NS:[EnumInNestedNS; 3] = [
EnumInNestedNS::A,
EnumInNestedNS::B,
EnumInNestedNS::C
];
#[allow(non_camel_case_types)]
const ENUM_NAMES_ENUM_IN_NESTED_N_S:[&'static str; 3] = [
const ENUM_NAMES_ENUM_IN_NESTED_NS:[&'static str; 3] = [
"A",
"B",
"C"
];
pub fn enum_name_enum_in_nested_n_s(e: EnumInNestedNS) -> &'static str {
pub fn enum_name_enum_in_nested_ns(e: EnumInNestedNS) -> &'static str {
let index: usize = e as usize;
ENUM_NAMES_ENUM_IN_NESTED_N_S[index]
ENUM_NAMES_ENUM_IN_NESTED_NS[index]
}
// struct StructInNestedNS, aligned to 4

View File

@@ -331,7 +331,7 @@ mod roundtrip_generated_code {
Some("foo"));
assert_eq!(mon.test_as_monster().unwrap().name(), Some("foo"));
assert_eq!(mon.test_as_test_simple_table_with_enum(), None);
assert_eq!(mon.test_as_my_game___example_2___monster(), None);
assert_eq!(mon.test_as_my_game_example_2_monster(), None);
}
#[test]
fn union_default() {