[Rust] Ensure unions are referenced with the correct path (#6422)

* Add codegen test for namespaced unions

* [Rust] Handle cross-namespace union use

* [Rust] Test namespace handling

* [Rust] Drop trailing whitespace in codegen

* [Rust] Set flags in generate_code.bat to match .sh

* [C#] Add additional namespace test file
diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp
index 0bd2799..1677ce8 100644
--- a/src/idl_gen_rust.cpp
+++ b/src/idl_gen_rust.cpp
@@ -759,7 +759,7 @@
     code_ += "impl flatbuffers::SimpleToVerifyInSlice for {{ENUM_NAME}} {}";
 
     if (enum_def.is_union) {
-      // Generate tyoesafe offset(s) for unions
+      // Generate typesafe offset(s) for unions
       code_.SetValue("NAME", Name(enum_def));
       code_.SetValue("UNION_OFFSET_NAME", Name(enum_def) + "UnionTableOffset");
       code_ += "pub struct {{UNION_OFFSET_NAME}} {}";
@@ -808,7 +808,7 @@
 
     // Get flatbuffers union key.
     // CASPER: add docstrings?
-    code_ += "  fn {{ENUM_NAME_SNAKE}}_type(&self) -> {{ENUM_NAME}} {";
+    code_ += "  pub fn {{ENUM_NAME_SNAKE}}_type(&self) -> {{ENUM_NAME}} {";
     code_ += "    match self {";
     code_ += "      Self::NONE => {{ENUM_NAME}}::NONE,";
     ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
@@ -1501,8 +1501,8 @@
           case ftUnionKey: return;
           case ftUnionValue: {
             const auto &enum_def = *type.enum_def;
-            code_.SetValue("ENUM_NAME", Name(enum_def));
-            code_.SetValue("NATIVE_ENUM_NAME", NativeName(enum_def));
+            code_.SetValue("ENUM_NAME", WrapInNameSpace(enum_def));
+            code_.SetValue("NATIVE_ENUM_NAME", NamespacedNativeName(enum_def));
             code_ +=
                 "      let {{FIELD_NAME}} = match "
                 "self.{{FIELD_NAME}}_type() {";
@@ -1730,7 +1730,7 @@
       }
       // Unions.
       EnumDef &union_def = *field.value.type.enum_def;
-      code_.SetValue("UNION_TYPE", Name(union_def));
+      code_.SetValue("UNION_TYPE", WrapInNameSpace(union_def));
       code_ +=
           "\n     .visit_union::<{{UNION_TYPE}}, _>("
           "&\"{{FIELD_NAME}}_type\", Self::{{OFFSET_NAME}}_TYPE, "
@@ -1878,7 +1878,7 @@
               code_ += "          }";
               code_ += "        },";
             });
-        code_ += "        _ => { ";
+        code_ += "        _ => {";
         code_ += "          let x: Option<()> = None;";
         code_ += "          ds.field(\"{{FIELD_NAME}}\", &x)";
         code_ += "        },";