Make `flatc` generate Rust files not requiring `std` (#7273)

* Set an explicit 2018 edition for Rust tests

* Replace all `std` usage with `core` and `alloc` in Rust code generator

* Update the generated files

* Make Rust tests actually use no_std when the corresponding feature is enabled
diff --git a/tests/arrays_test/my_game/example/array_struct_generated.rs b/tests/arrays_test/my_game/example/array_struct_generated.rs
index dea3655..3261f12 100644
--- a/tests/arrays_test/my_game/example/array_struct_generated.rs
+++ b/tests/arrays_test/my_game/example/array_struct_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct ArrayStruct, aligned to 8
@@ -13,8 +17,8 @@
     Self([0; 160])
   }
 }
-impl std::fmt::Debug for ArrayStruct {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for ArrayStruct {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("ArrayStruct")
       .field("a", &self.a())
       .field("b", &self.b())
@@ -47,7 +51,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const ArrayStruct as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -58,7 +62,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const ArrayStruct as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const ArrayStruct as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -158,7 +162,7 @@
 
   pub fn set_d(&mut self, x: &[NestedStruct; 2]) {
     unsafe {
-      std::ptr::copy(
+      core::ptr::copy(
         x.as_ptr() as *const u8,
         self.0.as_mut_ptr().add(72),
         64,
diff --git a/tests/arrays_test/my_game/example/array_table_generated.rs b/tests/arrays_test/my_game/example/array_table_generated.rs
index f46ac74..87cf6b7 100644
--- a/tests/arrays_test/my_game/example/array_table_generated.rs
+++ b/tests/arrays_test/my_game/example/array_table_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum ArrayTableOffset {}
@@ -103,8 +107,8 @@
   }
 }
 
-impl std::fmt::Debug for ArrayTable<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for ArrayTable<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("ArrayTable");
       ds.field("a", &self.a());
       ds.finish()
diff --git a/tests/arrays_test/my_game/example/nested_struct_generated.rs b/tests/arrays_test/my_game/example/nested_struct_generated.rs
index 48a6b91..9d841c7 100644
--- a/tests/arrays_test/my_game/example/nested_struct_generated.rs
+++ b/tests/arrays_test/my_game/example/nested_struct_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct NestedStruct, aligned to 8
@@ -13,8 +17,8 @@
     Self([0; 32])
   }
 }
-impl std::fmt::Debug for NestedStruct {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for NestedStruct {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("NestedStruct")
       .field("a", &self.a())
       .field("b", &self.b())
@@ -45,7 +49,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const NestedStruct as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -56,7 +60,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const NestedStruct as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const NestedStruct as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -129,7 +133,7 @@
 
   pub fn set_c(&mut self, x: &[TestEnum; 2]) {
     unsafe {
-      std::ptr::copy(
+      core::ptr::copy(
         x.as_ptr() as *const u8,
         self.0.as_mut_ptr().add(9),
         2,
diff --git a/tests/arrays_test/my_game/example/test_enum_generated.rs b/tests/arrays_test/my_game/example/test_enum_generated.rs
index 6dcc1cb..38a4696 100644
--- a/tests/arrays_test/my_game/example/test_enum_generated.rs
+++ b/tests/arrays_test/my_game/example/test_enum_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +46,8 @@
     }
   }
 }
-impl std::fmt::Debug for TestEnum {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for TestEnum {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/include_test1/my_game/other_name_space/from_include_generated.rs b/tests/include_test1/my_game/other_name_space/from_include_generated.rs
index 048bafd..54be3d6 100644
--- a/tests/include_test1/my_game/other_name_space/from_include_generated.rs
+++ b/tests/include_test1/my_game/other_name_space/from_include_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -34,8 +38,8 @@
     }
   }
 }
-impl std::fmt::Debug for FromInclude {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for FromInclude {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/include_test1/my_game/other_name_space/table_b_generated.rs b/tests/include_test1/my_game/other_name_space/table_b_generated.rs
index 46a99cb..edb14bc 100644
--- a/tests/include_test1/my_game/other_name_space/table_b_generated.rs
+++ b/tests/include_test1/my_game/other_name_space/table_b_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TableBOffset {}
@@ -103,8 +107,8 @@
   }
 }
 
-impl std::fmt::Debug for TableB<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableB<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableB");
       ds.field("a", &self.a());
       ds.finish()
diff --git a/tests/include_test1/my_game/other_name_space/unused_generated.rs b/tests/include_test1/my_game/other_name_space/unused_generated.rs
index 1dc5913..d0b3f3a 100644
--- a/tests/include_test1/my_game/other_name_space/unused_generated.rs
+++ b/tests/include_test1/my_game/other_name_space/unused_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct Unused, aligned to 4
@@ -13,8 +17,8 @@
     Self([0; 4])
   }
 }
-impl std::fmt::Debug for Unused {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Unused {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Unused")
       .field("a", &self.a())
       .finish()
@@ -42,7 +46,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -53,7 +57,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/include_test1/table_a_generated.rs b/tests/include_test1/table_a_generated.rs
index 9188b29..5123445 100644
--- a/tests/include_test1/table_a_generated.rs
+++ b/tests/include_test1/table_a_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TableAOffset {}
@@ -103,8 +107,8 @@
   }
 }
 
-impl std::fmt::Debug for TableA<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableA<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableA");
       ds.field("b", &self.b());
       ds.finish()
diff --git a/tests/include_test2/my_game/other_name_space/from_include_generated.rs b/tests/include_test2/my_game/other_name_space/from_include_generated.rs
index 048bafd..54be3d6 100644
--- a/tests/include_test2/my_game/other_name_space/from_include_generated.rs
+++ b/tests/include_test2/my_game/other_name_space/from_include_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -34,8 +38,8 @@
     }
   }
 }
-impl std::fmt::Debug for FromInclude {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for FromInclude {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/include_test2/my_game/other_name_space/table_b_generated.rs b/tests/include_test2/my_game/other_name_space/table_b_generated.rs
index 46a99cb..edb14bc 100644
--- a/tests/include_test2/my_game/other_name_space/table_b_generated.rs
+++ b/tests/include_test2/my_game/other_name_space/table_b_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TableBOffset {}
@@ -103,8 +107,8 @@
   }
 }
 
-impl std::fmt::Debug for TableB<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableB<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableB");
       ds.field("a", &self.a());
       ds.finish()
diff --git a/tests/include_test2/my_game/other_name_space/unused_generated.rs b/tests/include_test2/my_game/other_name_space/unused_generated.rs
index 1dc5913..d0b3f3a 100644
--- a/tests/include_test2/my_game/other_name_space/unused_generated.rs
+++ b/tests/include_test2/my_game/other_name_space/unused_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct Unused, aligned to 4
@@ -13,8 +17,8 @@
     Self([0; 4])
   }
 }
-impl std::fmt::Debug for Unused {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Unused {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Unused")
       .field("a", &self.a())
       .finish()
@@ -42,7 +46,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -53,7 +57,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/include_test2/table_a_generated.rs b/tests/include_test2/table_a_generated.rs
index 9188b29..5123445 100644
--- a/tests/include_test2/table_a_generated.rs
+++ b/tests/include_test2/table_a_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TableAOffset {}
@@ -103,8 +107,8 @@
   }
 }
 
-impl std::fmt::Debug for TableA<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableA<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableA");
       ds.field("b", &self.b());
       ds.finish()
diff --git a/tests/keyword_test/keyword_test/abc_generated.rs b/tests/keyword_test/keyword_test/abc_generated.rs
index 99b43e4..39dc188 100644
--- a/tests/keyword_test/keyword_test/abc_generated.rs
+++ b/tests/keyword_test/keyword_test/abc_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +46,8 @@
     }
   }
 }
-impl std::fmt::Debug for ABC {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for ABC {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/keyword_test/keyword_test/keywords_in_table_generated.rs b/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
index 0790048..0b9939b 100644
--- a/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
+++ b/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum KeywordsInTableOffset {}
@@ -146,8 +150,8 @@
   }
 }
 
-impl std::fmt::Debug for KeywordsInTable<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for KeywordsInTable<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("KeywordsInTable");
       ds.field("is", &self.is());
       ds.field("private", &self.private());
diff --git a/tests/keyword_test/keyword_test/keywords_in_union_generated.rs b/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
index cf03797..65df3fe 100644
--- a/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
+++ b/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +46,8 @@
     }
   }
 }
-impl std::fmt::Debug for KeywordsInUnion {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for KeywordsInUnion {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
@@ -128,7 +132,7 @@
   /// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
   pub fn take_static_(&mut self) -> Option<Box<KeywordsInTableT>> {
     if let Self::Static_(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::Static_(w) = v {
         Some(w)
       } else {
@@ -149,7 +153,7 @@
   /// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
   pub fn take_internal(&mut self) -> Option<Box<KeywordsInTableT>> {
     if let Self::Internal(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::Internal(w) = v {
         Some(w)
       } else {
diff --git a/tests/keyword_test/keyword_test/public_generated.rs b/tests/keyword_test/keyword_test/public_generated.rs
index 2de4c0b..e2befd3 100644
--- a/tests/keyword_test/keyword_test/public_generated.rs
+++ b/tests/keyword_test/keyword_test/public_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -34,8 +38,8 @@
     }
   }
 }
-impl std::fmt::Debug for public {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for public {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/monster_test/my_game/example/ability_generated.rs b/tests/monster_test/my_game/example/ability_generated.rs
index 5746e8e..8c23c11 100644
--- a/tests/monster_test/my_game/example/ability_generated.rs
+++ b/tests/monster_test/my_game/example/ability_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct Ability, aligned to 4
@@ -13,8 +17,8 @@
     Self([0; 8])
   }
 }
-impl std::fmt::Debug for Ability {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Ability {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Ability")
       .field("id", &self.id())
       .field("distance", &self.distance())
@@ -43,7 +47,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -54,7 +58,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -115,7 +119,7 @@
   }
 
   #[inline]
-  pub fn key_compare_with_value(&self, val: u32) -> ::std::cmp::Ordering {
+  pub fn key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering {
     let key = self.id();
     key.cmp(&val)
   }
diff --git a/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs b/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs
index 321007a..32e31ee 100644
--- a/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs
+++ b/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -46,8 +50,8 @@
     }
   }
 }
-impl std::fmt::Debug for AnyAmbiguousAliases {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for AnyAmbiguousAliases {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
@@ -135,7 +139,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_m1(&mut self) -> Option<Box<MonsterT>> {
     if let Self::M1(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M1(w) = v {
         Some(w)
       } else {
@@ -156,7 +160,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_m2(&mut self) -> Option<Box<MonsterT>> {
     if let Self::M2(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M2(w) = v {
         Some(w)
       } else {
@@ -177,7 +181,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_m3(&mut self) -> Option<Box<MonsterT>> {
     if let Self::M3(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M3(w) = v {
         Some(w)
       } else {
diff --git a/tests/monster_test/my_game/example/any_generated.rs b/tests/monster_test/my_game/example/any_generated.rs
index 6f7f6fd..4008dc0 100644
--- a/tests/monster_test/my_game/example/any_generated.rs
+++ b/tests/monster_test/my_game/example/any_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -46,8 +50,8 @@
     }
   }
 }
-impl std::fmt::Debug for Any {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Any {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
@@ -135,7 +139,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_monster(&mut self) -> Option<Box<MonsterT>> {
     if let Self::Monster(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::Monster(w) = v {
         Some(w)
       } else {
@@ -156,7 +160,7 @@
   /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
   pub fn take_test_simple_table_with_enum(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
     if let Self::TestSimpleTableWithEnum(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::TestSimpleTableWithEnum(w) = v {
         Some(w)
       } else {
@@ -177,7 +181,7 @@
   /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
   pub fn take_my_game_example_2_monster(&mut self) -> Option<Box<super::example_2::MonsterT>> {
     if let Self::MyGameExample2Monster(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::MyGameExample2Monster(w) = v {
         Some(w)
       } else {
diff --git a/tests/monster_test/my_game/example/any_unique_aliases_generated.rs b/tests/monster_test/my_game/example/any_unique_aliases_generated.rs
index 1749d5d..1337a29 100644
--- a/tests/monster_test/my_game/example/any_unique_aliases_generated.rs
+++ b/tests/monster_test/my_game/example/any_unique_aliases_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -46,8 +50,8 @@
     }
   }
 }
-impl std::fmt::Debug for AnyUniqueAliases {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for AnyUniqueAliases {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
@@ -135,7 +139,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_m(&mut self) -> Option<Box<MonsterT>> {
     if let Self::M(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M(w) = v {
         Some(w)
       } else {
@@ -156,7 +160,7 @@
   /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
   pub fn take_ts(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
     if let Self::TS(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::TS(w) = v {
         Some(w)
       } else {
@@ -177,7 +181,7 @@
   /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
   pub fn take_m2(&mut self) -> Option<Box<super::example_2::MonsterT>> {
     if let Self::M2(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M2(w) = v {
         Some(w)
       } else {
diff --git a/tests/monster_test/my_game/example/color_generated.rs b/tests/monster_test/my_game/example/color_generated.rs
index 4a3282b..2679798 100644
--- a/tests/monster_test/my_game/example/color_generated.rs
+++ b/tests/monster_test/my_game/example/color_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[allow(non_upper_case_globals)]
diff --git a/tests/monster_test/my_game/example/long_enum_generated.rs b/tests/monster_test/my_game/example/long_enum_generated.rs
index b22f826..7844af5 100644
--- a/tests/monster_test/my_game/example/long_enum_generated.rs
+++ b/tests/monster_test/my_game/example/long_enum_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[allow(non_upper_case_globals)]
diff --git a/tests/monster_test/my_game/example/monster_generated.rs b/tests/monster_test/my_game/example/monster_generated.rs
index 58e7628..cf1b33c 100644
--- a/tests/monster_test/my_game/example/monster_generated.rs
+++ b/tests/monster_test/my_game/example/monster_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum MonsterOffset {}
@@ -379,7 +383,7 @@
   }
 
   #[inline]
-  pub fn key_compare_with_value(&self, val: & str) -> ::std::cmp::Ordering {
+  pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering {
     let key = self.name();
     key.cmp(val)
   }
@@ -1116,8 +1120,8 @@
   }
 }
 
-impl std::fmt::Debug for Monster<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Monster<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("Monster");
       ds.field("pos", &self.pos());
       ds.field("mana", &self.mana());
diff --git a/tests/monster_test/my_game/example/race_generated.rs b/tests/monster_test/my_game/example/race_generated.rs
index ab012f9..a2a1593 100644
--- a/tests/monster_test/my_game/example/race_generated.rs
+++ b/tests/monster_test/my_game/example/race_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -46,8 +50,8 @@
     }
   }
 }
-impl std::fmt::Debug for Race {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Race {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/monster_test/my_game/example/referrable_generated.rs b/tests/monster_test/my_game/example/referrable_generated.rs
index 877e3b8..0395ab2 100644
--- a/tests/monster_test/my_game/example/referrable_generated.rs
+++ b/tests/monster_test/my_game/example/referrable_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum ReferrableOffset {}
@@ -57,7 +61,7 @@
   }
 
   #[inline]
-  pub fn key_compare_with_value(&self, val: u64) -> ::std::cmp::Ordering {
+  pub fn key_compare_with_value(&self, val: u64) -> ::core::cmp::Ordering {
     let key = self.id();
     key.cmp(&val)
   }
@@ -111,8 +115,8 @@
   }
 }
 
-impl std::fmt::Debug for Referrable<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Referrable<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("Referrable");
       ds.field("id", &self.id());
       ds.finish()
diff --git a/tests/monster_test/my_game/example/stat_generated.rs b/tests/monster_test/my_game/example/stat_generated.rs
index d6e5fad..b939f19 100644
--- a/tests/monster_test/my_game/example/stat_generated.rs
+++ b/tests/monster_test/my_game/example/stat_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum StatOffset {}
@@ -75,7 +79,7 @@
   }
 
   #[inline]
-  pub fn key_compare_with_value(&self, val: u16) -> ::std::cmp::Ordering {
+  pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering {
     let key = self.count();
     key.cmp(&val)
   }
@@ -143,8 +147,8 @@
   }
 }
 
-impl std::fmt::Debug for Stat<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Stat<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("Stat");
       ds.field("id", &self.id());
       ds.field("val", &self.val());
diff --git a/tests/monster_test/my_game/example/struct_of_structs_generated.rs b/tests/monster_test/my_game/example/struct_of_structs_generated.rs
index 9994f7e..9747e0c 100644
--- a/tests/monster_test/my_game/example/struct_of_structs_generated.rs
+++ b/tests/monster_test/my_game/example/struct_of_structs_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct StructOfStructs, aligned to 4
@@ -13,8 +17,8 @@
     Self([0; 20])
   }
 }
-impl std::fmt::Debug for StructOfStructs {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for StructOfStructs {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("StructOfStructs")
       .field("a", &self.a())
       .field("b", &self.b())
@@ -44,7 +48,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -55,7 +59,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const StructOfStructs as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const StructOfStructs as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs b/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs
index 9a92dd1..b2d22b7 100644
--- a/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs
+++ b/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct StructOfStructsOfStructs, aligned to 4
@@ -13,8 +17,8 @@
     Self([0; 20])
   }
 }
-impl std::fmt::Debug for StructOfStructsOfStructs {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for StructOfStructsOfStructs {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("StructOfStructsOfStructs")
       .field("a", &self.a())
       .finish()
@@ -42,7 +46,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -53,7 +57,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const StructOfStructsOfStructs as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const StructOfStructsOfStructs as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test/my_game/example/test_generated.rs b/tests/monster_test/my_game/example/test_generated.rs
index 187b7cd..7d9885c 100644
--- a/tests/monster_test/my_game/example/test_generated.rs
+++ b/tests/monster_test/my_game/example/test_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct Test, aligned to 2
@@ -13,8 +17,8 @@
     Self([0; 4])
   }
 }
-impl std::fmt::Debug for Test {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Test {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Test")
       .field("a", &self.a())
       .field("b", &self.b())
@@ -43,7 +47,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Test as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Test as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -54,7 +58,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Test as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Test as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs b/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs
index 6ebe31f..0e3c717 100644
--- a/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs
+++ b/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TestSimpleTableWithEnumOffset {}
@@ -101,8 +105,8 @@
   }
 }
 
-impl std::fmt::Debug for TestSimpleTableWithEnum<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TestSimpleTableWithEnum<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TestSimpleTableWithEnum");
       ds.field("color", &self.color());
       ds.finish()
diff --git a/tests/monster_test/my_game/example/type_aliases_generated.rs b/tests/monster_test/my_game/example/type_aliases_generated.rs
index 5b3ede5..f232d3e 100644
--- a/tests/monster_test/my_game/example/type_aliases_generated.rs
+++ b/tests/monster_test/my_game/example/type_aliases_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TypeAliasesOffset {}
@@ -270,8 +274,8 @@
   }
 }
 
-impl std::fmt::Debug for TypeAliases<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TypeAliases<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TypeAliases");
       ds.field("i8_", &self.i8_());
       ds.field("u8_", &self.u8_());
diff --git a/tests/monster_test/my_game/example/vec_3_generated.rs b/tests/monster_test/my_game/example/vec_3_generated.rs
index e5a25bb..736bf35 100644
--- a/tests/monster_test/my_game/example/vec_3_generated.rs
+++ b/tests/monster_test/my_game/example/vec_3_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct Vec3, aligned to 8
@@ -13,8 +17,8 @@
     Self([0; 32])
   }
 }
-impl std::fmt::Debug for Vec3 {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Vec3 {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Vec3")
       .field("x", &self.x())
       .field("y", &self.y())
@@ -47,7 +51,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -58,7 +62,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test/my_game/example_2/monster_generated.rs b/tests/monster_test/my_game/example_2/monster_generated.rs
index 54384b5..8925b5a 100644
--- a/tests/monster_test/my_game/example_2/monster_generated.rs
+++ b/tests/monster_test/my_game/example_2/monster_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum MonsterOffset {}
@@ -85,8 +89,8 @@
   }
 }
 
-impl std::fmt::Debug for Monster<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Monster<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("Monster");
       ds.finish()
   }
diff --git a/tests/monster_test/my_game/in_parent_namespace_generated.rs b/tests/monster_test/my_game/in_parent_namespace_generated.rs
index aabd4b8..216dfa3 100644
--- a/tests/monster_test/my_game/in_parent_namespace_generated.rs
+++ b/tests/monster_test/my_game/in_parent_namespace_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum InParentNamespaceOffset {}
@@ -85,8 +89,8 @@
   }
 }
 
-impl std::fmt::Debug for InParentNamespace<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for InParentNamespace<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("InParentNamespace");
       ds.finish()
   }
diff --git a/tests/monster_test/my_game/other_name_space/from_include_generated.rs b/tests/monster_test/my_game/other_name_space/from_include_generated.rs
index 048bafd..54be3d6 100644
--- a/tests/monster_test/my_game/other_name_space/from_include_generated.rs
+++ b/tests/monster_test/my_game/other_name_space/from_include_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -34,8 +38,8 @@
     }
   }
 }
-impl std::fmt::Debug for FromInclude {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for FromInclude {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/monster_test/my_game/other_name_space/table_b_generated.rs b/tests/monster_test/my_game/other_name_space/table_b_generated.rs
index 46a99cb..edb14bc 100644
--- a/tests/monster_test/my_game/other_name_space/table_b_generated.rs
+++ b/tests/monster_test/my_game/other_name_space/table_b_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TableBOffset {}
@@ -103,8 +107,8 @@
   }
 }
 
-impl std::fmt::Debug for TableB<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableB<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableB");
       ds.field("a", &self.a());
       ds.finish()
diff --git a/tests/monster_test/my_game/other_name_space/unused_generated.rs b/tests/monster_test/my_game/other_name_space/unused_generated.rs
index 1dc5913..d0b3f3a 100644
--- a/tests/monster_test/my_game/other_name_space/unused_generated.rs
+++ b/tests/monster_test/my_game/other_name_space/unused_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct Unused, aligned to 4
@@ -13,8 +17,8 @@
     Self([0; 4])
   }
 }
-impl std::fmt::Debug for Unused {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Unused {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Unused")
       .field("a", &self.a())
       .finish()
@@ -42,7 +46,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -53,7 +57,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test/table_a_generated.rs b/tests/monster_test/table_a_generated.rs
index 9188b29..5123445 100644
--- a/tests/monster_test/table_a_generated.rs
+++ b/tests/monster_test/table_a_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TableAOffset {}
@@ -103,8 +107,8 @@
   }
 }
 
-impl std::fmt::Debug for TableA<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableA<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableA");
       ds.field("b", &self.b());
       ds.finish()
diff --git a/tests/monster_test_serialize/my_game/example/ability_generated.rs b/tests/monster_test_serialize/my_game/example/ability_generated.rs
index cdc7882..a0fc73c 100644
--- a/tests/monster_test_serialize/my_game/example/ability_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/ability_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +19,8 @@
     Self([0; 8])
   }
 }
-impl std::fmt::Debug for Ability {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Ability {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Ability")
       .field("id", &self.id())
       .field("distance", &self.distance())
@@ -45,7 +49,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -56,7 +60,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -129,7 +133,7 @@
   }
 
   #[inline]
-  pub fn key_compare_with_value(&self, val: u32) -> ::std::cmp::Ordering {
+  pub fn key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering {
     let key = self.id();
     key.cmp(&val)
   }
diff --git a/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs b/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs
index 2e757a8..9885363 100644
--- a/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -48,8 +52,8 @@
     }
   }
 }
-impl std::fmt::Debug for AnyAmbiguousAliases {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for AnyAmbiguousAliases {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
@@ -146,7 +150,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_m1(&mut self) -> Option<Box<MonsterT>> {
     if let Self::M1(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M1(w) = v {
         Some(w)
       } else {
@@ -167,7 +171,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_m2(&mut self) -> Option<Box<MonsterT>> {
     if let Self::M2(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M2(w) = v {
         Some(w)
       } else {
@@ -188,7 +192,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_m3(&mut self) -> Option<Box<MonsterT>> {
     if let Self::M3(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M3(w) = v {
         Some(w)
       } else {
diff --git a/tests/monster_test_serialize/my_game/example/any_generated.rs b/tests/monster_test_serialize/my_game/example/any_generated.rs
index d572642..1af99de 100644
--- a/tests/monster_test_serialize/my_game/example/any_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/any_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -48,8 +52,8 @@
     }
   }
 }
-impl std::fmt::Debug for Any {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Any {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
@@ -146,7 +150,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_monster(&mut self) -> Option<Box<MonsterT>> {
     if let Self::Monster(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::Monster(w) = v {
         Some(w)
       } else {
@@ -167,7 +171,7 @@
   /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
   pub fn take_test_simple_table_with_enum(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
     if let Self::TestSimpleTableWithEnum(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::TestSimpleTableWithEnum(w) = v {
         Some(w)
       } else {
@@ -188,7 +192,7 @@
   /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
   pub fn take_my_game_example_2_monster(&mut self) -> Option<Box<super::example_2::MonsterT>> {
     if let Self::MyGameExample2Monster(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::MyGameExample2Monster(w) = v {
         Some(w)
       } else {
diff --git a/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs b/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs
index 8a3fa66..a6897dd 100644
--- a/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -48,8 +52,8 @@
     }
   }
 }
-impl std::fmt::Debug for AnyUniqueAliases {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for AnyUniqueAliases {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
@@ -146,7 +150,7 @@
   /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
   pub fn take_m(&mut self) -> Option<Box<MonsterT>> {
     if let Self::M(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M(w) = v {
         Some(w)
       } else {
@@ -167,7 +171,7 @@
   /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
   pub fn take_ts(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
     if let Self::TS(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::TS(w) = v {
         Some(w)
       } else {
@@ -188,7 +192,7 @@
   /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
   pub fn take_m2(&mut self) -> Option<Box<super::example_2::MonsterT>> {
     if let Self::M2(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::M2(w) = v {
         Some(w)
       } else {
diff --git a/tests/monster_test_serialize/my_game/example/color_generated.rs b/tests/monster_test_serialize/my_game/example/color_generated.rs
index e27f79c..cf6b78e 100644
--- a/tests/monster_test_serialize/my_game/example/color_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/color_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
diff --git a/tests/monster_test_serialize/my_game/example/long_enum_generated.rs b/tests/monster_test_serialize/my_game/example/long_enum_generated.rs
index f513d29..16b29b4 100644
--- a/tests/monster_test_serialize/my_game/example/long_enum_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/long_enum_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
diff --git a/tests/monster_test_serialize/my_game/example/monster_generated.rs b/tests/monster_test_serialize/my_game/example/monster_generated.rs
index cd5730f..c6aa81b 100644
--- a/tests/monster_test_serialize/my_game/example/monster_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/monster_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -381,7 +385,7 @@
   }
 
   #[inline]
-  pub fn key_compare_with_value(&self, val: & str) -> ::std::cmp::Ordering {
+  pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering {
     let key = self.name();
     key.cmp(val)
   }
@@ -1335,8 +1339,8 @@
   }
 }
 
-impl std::fmt::Debug for Monster<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Monster<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("Monster");
       ds.field("pos", &self.pos());
       ds.field("mana", &self.mana());
diff --git a/tests/monster_test_serialize/my_game/example/race_generated.rs b/tests/monster_test_serialize/my_game/example/race_generated.rs
index 63754ff..4fddd64 100644
--- a/tests/monster_test_serialize/my_game/example/race_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/race_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -48,8 +52,8 @@
     }
   }
 }
-impl std::fmt::Debug for Race {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Race {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/monster_test_serialize/my_game/example/referrable_generated.rs b/tests/monster_test_serialize/my_game/example/referrable_generated.rs
index 490980d..72543fa 100644
--- a/tests/monster_test_serialize/my_game/example/referrable_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/referrable_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -59,7 +63,7 @@
   }
 
   #[inline]
-  pub fn key_compare_with_value(&self, val: u64) -> ::std::cmp::Ordering {
+  pub fn key_compare_with_value(&self, val: u64) -> ::core::cmp::Ordering {
     let key = self.id();
     key.cmp(&val)
   }
@@ -124,8 +128,8 @@
   }
 }
 
-impl std::fmt::Debug for Referrable<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Referrable<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("Referrable");
       ds.field("id", &self.id());
       ds.finish()
diff --git a/tests/monster_test_serialize/my_game/example/stat_generated.rs b/tests/monster_test_serialize/my_game/example/stat_generated.rs
index abfa05d..38e10a9 100644
--- a/tests/monster_test_serialize/my_game/example/stat_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/stat_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -77,7 +81,7 @@
   }
 
   #[inline]
-  pub fn key_compare_with_value(&self, val: u16) -> ::std::cmp::Ordering {
+  pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering {
     let key = self.count();
     key.cmp(&val)
   }
@@ -162,8 +166,8 @@
   }
 }
 
-impl std::fmt::Debug for Stat<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Stat<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("Stat");
       ds.field("id", &self.id());
       ds.field("val", &self.val());
diff --git a/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs b/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs
index 75b8865..5a7eb5a 100644
--- a/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +19,8 @@
     Self([0; 20])
   }
 }
-impl std::fmt::Debug for StructOfStructs {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for StructOfStructs {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("StructOfStructs")
       .field("a", &self.a())
       .field("b", &self.b())
@@ -46,7 +50,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -57,7 +61,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const StructOfStructs as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const StructOfStructs as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs b/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs
index 9bf2ea2..d6acf9d 100644
--- a/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +19,8 @@
     Self([0; 20])
   }
 }
-impl std::fmt::Debug for StructOfStructsOfStructs {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for StructOfStructsOfStructs {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("StructOfStructsOfStructs")
       .field("a", &self.a())
       .finish()
@@ -44,7 +48,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -55,7 +59,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const StructOfStructsOfStructs as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const StructOfStructsOfStructs as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test_serialize/my_game/example/test_generated.rs b/tests/monster_test_serialize/my_game/example/test_generated.rs
index 56493ba..c5e5132 100644
--- a/tests/monster_test_serialize/my_game/example/test_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/test_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +19,8 @@
     Self([0; 4])
   }
 }
-impl std::fmt::Debug for Test {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Test {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Test")
       .field("a", &self.a())
       .field("b", &self.b())
@@ -45,7 +49,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Test as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Test as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -56,7 +60,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Test as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Test as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs b/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs
index cd64311..b9dce52 100644
--- a/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -114,8 +118,8 @@
   }
 }
 
-impl std::fmt::Debug for TestSimpleTableWithEnum<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TestSimpleTableWithEnum<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TestSimpleTableWithEnum");
       ds.field("color", &self.color());
       ds.finish()
diff --git a/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs b/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs
index 44d1198..2a8d52a 100644
--- a/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -302,8 +306,8 @@
   }
 }
 
-impl std::fmt::Debug for TypeAliases<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TypeAliases<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TypeAliases");
       ds.field("i8_", &self.i8_());
       ds.field("u8_", &self.u8_());
diff --git a/tests/monster_test_serialize/my_game/example/vec_3_generated.rs b/tests/monster_test_serialize/my_game/example/vec_3_generated.rs
index f04d0e8..3419089 100644
--- a/tests/monster_test_serialize/my_game/example/vec_3_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/vec_3_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +19,8 @@
     Self([0; 32])
   }
 }
-impl std::fmt::Debug for Vec3 {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Vec3 {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Vec3")
       .field("x", &self.x())
       .field("y", &self.y())
@@ -49,7 +53,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -60,7 +64,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test_serialize/my_game/example_2/monster_generated.rs b/tests/monster_test_serialize/my_game/example_2/monster_generated.rs
index 7687c5e..627278b 100644
--- a/tests/monster_test_serialize/my_game/example_2/monster_generated.rs
+++ b/tests/monster_test_serialize/my_game/example_2/monster_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -97,8 +101,8 @@
   }
 }
 
-impl std::fmt::Debug for Monster<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Monster<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("Monster");
       ds.finish()
   }
diff --git a/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs b/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs
index b2b0a09..4d61f40 100644
--- a/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs
+++ b/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -97,8 +101,8 @@
   }
 }
 
-impl std::fmt::Debug for InParentNamespace<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for InParentNamespace<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("InParentNamespace");
       ds.finish()
   }
diff --git a/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs b/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs
index 06a0fa8..d1440f5 100644
--- a/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs
+++ b/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -36,8 +40,8 @@
     }
   }
 }
-impl std::fmt::Debug for FromInclude {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for FromInclude {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs b/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs
index f09e175..6af0c32 100644
--- a/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs
+++ b/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -120,8 +124,8 @@
   }
 }
 
-impl std::fmt::Debug for TableB<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableB<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableB");
       ds.field("a", &self.a());
       ds.finish()
diff --git a/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs b/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs
index 7b91447..bf35e72 100644
--- a/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs
+++ b/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +19,8 @@
     Self([0; 4])
   }
 }
-impl std::fmt::Debug for Unused {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Unused {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("Unused")
       .field("a", &self.a())
       .finish()
@@ -44,7 +48,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -55,7 +59,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/monster_test_serialize/table_a_generated.rs b/tests/monster_test_serialize/table_a_generated.rs
index eb03f49..9ee3747 100644
--- a/tests/monster_test_serialize/table_a_generated.rs
+++ b/tests/monster_test_serialize/table_a_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 extern crate serde;
 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
 use self::flatbuffers::{EndianScalar, Follow};
@@ -120,8 +124,8 @@
   }
 }
 
-impl std::fmt::Debug for TableA<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableA<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableA");
       ds.field("b", &self.b());
       ds.finish()
diff --git a/tests/more_defaults/abc_generated.rs b/tests/more_defaults/abc_generated.rs
index 8622d9b..42f716b 100644
--- a/tests/more_defaults/abc_generated.rs
+++ b/tests/more_defaults/abc_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +46,8 @@
     }
   }
 }
-impl std::fmt::Debug for ABC {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for ABC {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/more_defaults/more_defaults_generated.rs b/tests/more_defaults/more_defaults_generated.rs
index 0a88105..7de58f6 100644
--- a/tests/more_defaults/more_defaults_generated.rs
+++ b/tests/more_defaults/more_defaults_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum MoreDefaultsOffset {}
@@ -194,8 +198,8 @@
   }
 }
 
-impl std::fmt::Debug for MoreDefaults<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for MoreDefaults<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("MoreDefaults");
       ds.field("ints", &self.ints());
       ds.field("floats", &self.floats());
diff --git a/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs
index b636638..5e59522 100644
--- a/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +46,8 @@
     }
   }
 }
-impl std::fmt::Debug for EnumInNestedNS {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for EnumInNestedNS {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs
index 55fff40..b26afe8 100644
--- a/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 // struct StructInNestedNS, aligned to 4
@@ -13,8 +17,8 @@
     Self([0; 8])
   }
 }
-impl std::fmt::Debug for StructInNestedNS {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for StructInNestedNS {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     f.debug_struct("StructInNestedNS")
       .field("a", &self.a())
       .field("b", &self.b())
@@ -43,7 +47,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, Self::size())
+            ::core::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
@@ -54,7 +58,7 @@
     #[inline]
     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
         let src = unsafe {
-            ::std::slice::from_raw_parts(*self as *const StructInNestedNS as *const u8, Self::size())
+            ::core::slice::from_raw_parts(*self as *const StructInNestedNS as *const u8, Self::size())
         };
         dst.copy_from_slice(src);
     }
diff --git a/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs
index 10d5b7c..f8054e8 100644
--- a/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TableInNestedNSOffset {}
@@ -101,8 +105,8 @@
   }
 }
 
-impl std::fmt::Debug for TableInNestedNS<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableInNestedNS<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableInNestedNS");
       ds.field("foo", &self.foo());
       ds.finish()
diff --git a/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs
index 8d650a5..1758f88 100644
--- a/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -38,8 +42,8 @@
     }
   }
 }
-impl std::fmt::Debug for UnionInNestedNS {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for UnionInNestedNS {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
@@ -121,7 +125,7 @@
   /// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE.
   pub fn take_table_in_nested_ns(&mut self) -> Option<Box<TableInNestedNST>> {
     if let Self::TableInNestedNS(_) = self {
-      let v = std::mem::replace(self, Self::NONE);
+      let v = core::mem::replace(self, Self::NONE);
       if let Self::TableInNestedNS(w) = v {
         Some(w)
       } else {
diff --git a/tests/namespace_test/namespace_a/second_table_in_a_generated.rs b/tests/namespace_test/namespace_a/second_table_in_a_generated.rs
index d63438b..91561b9 100644
--- a/tests/namespace_test/namespace_a/second_table_in_a_generated.rs
+++ b/tests/namespace_test/namespace_a/second_table_in_a_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum SecondTableInAOffset {}
@@ -103,8 +107,8 @@
   }
 }
 
-impl std::fmt::Debug for SecondTableInA<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for SecondTableInA<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("SecondTableInA");
       ds.field("refer_to_c", &self.refer_to_c());
       ds.finish()
diff --git a/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs b/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs
index 0a16074..5a76dbd 100644
--- a/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TableInFirstNSOffset {}
@@ -185,8 +189,8 @@
   }
 }
 
-impl std::fmt::Debug for TableInFirstNS<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableInFirstNS<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableInFirstNS");
       ds.field("foo_table", &self.foo_table());
       ds.field("foo_enum", &self.foo_enum());
diff --git a/tests/namespace_test/namespace_c/table_in_c_generated.rs b/tests/namespace_test/namespace_c/table_in_c_generated.rs
index d4ac783..6d548cf 100644
--- a/tests/namespace_test/namespace_c/table_in_c_generated.rs
+++ b/tests/namespace_test/namespace_c/table_in_c_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum TableInCOffset {}
@@ -120,8 +124,8 @@
   }
 }
 
-impl std::fmt::Debug for TableInC<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableInC<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("TableInC");
       ds.field("refer_to_a1", &self.refer_to_a1());
       ds.field("refer_to_a2", &self.refer_to_a2());
diff --git a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
index 226e9ec..b57053d 100644
--- a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
+++ b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +46,8 @@
     }
   }
 }
-impl std::fmt::Debug for OptionalByte {
-  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for OptionalByte {
+  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
     if let Some(name) = self.variant_name() {
       f.write_str(name)
     } else {
diff --git a/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs b/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
index 407e278..bc5375a 100644
--- a/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
+++ b/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
@@ -1,7 +1,11 @@
 // automatically generated by the FlatBuffers compiler, do not modify
+extern crate alloc;
 extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
 use self::flatbuffers::{EndianScalar, Follow};
 use super::*;
 pub enum ScalarStuffOffset {}
@@ -626,8 +630,8 @@
   }
 }
 
-impl std::fmt::Debug for ScalarStuff<'_> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for ScalarStuff<'_> {
+  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
     let mut ds = f.debug_struct("ScalarStuff");
       ds.field("just_i8", &self.just_i8());
       ds.field("maybe_i8", &self.maybe_i8());
diff --git a/tests/rust_usage_test/Cargo.toml b/tests/rust_usage_test/Cargo.toml
index e676970..d5731e7 100644
--- a/tests/rust_usage_test/Cargo.toml
+++ b/tests/rust_usage_test/Cargo.toml
@@ -4,6 +4,7 @@
 authors = ["Robert Winslow <hello@rwinslow.com>",
            "Casper Neo <cneo@google.com>",
            "FlatBuffers Maintainers"]
+edition = "2018"
 
 [dependencies]
 flatbuffers = { path = "../../rust/flatbuffers", default-features = false }
diff --git a/tests/rust_usage_test/benches/flatbuffers_benchmarks.rs b/tests/rust_usage_test/benches/flatbuffers_benchmarks.rs
index 580d433..7d72501 100644
--- a/tests/rust_usage_test/benches/flatbuffers_benchmarks.rs
+++ b/tests/rust_usage_test/benches/flatbuffers_benchmarks.rs
@@ -14,9 +14,8 @@
  * limitations under the License.
  */
 
+use bencher::{benchmark_group, Bencher};
 use flatbuffers;
-use bencher::Bencher;
-
 
 #[allow(dead_code, unused_imports)]
 #[path = "../../monster_test/mod.rs"]
diff --git a/tests/rust_usage_test/benches/flexbuffers_benchmarks.rs b/tests/rust_usage_test/benches/flexbuffers_benchmarks.rs
index 1b9a8fb..2684291 100644
--- a/tests/rust_usage_test/benches/flexbuffers_benchmarks.rs
+++ b/tests/rust_usage_test/benches/flexbuffers_benchmarks.rs
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-use bencher::Bencher;
+use bencher::{benchmark_group, benchmark_main, Bencher};
 use flexbuffers::*;
 
 fn push_vec_u64_to_map(b: &mut Bencher) {
diff --git a/tests/rust_usage_test/tests/arrays_test.rs b/tests/rust_usage_test/tests/arrays_test.rs
index faa0ac8..e92e862 100644
--- a/tests/rust_usage_test/tests/arrays_test.rs
+++ b/tests/rust_usage_test/tests/arrays_test.rs
@@ -1,16 +1,23 @@
+#![no_std]
+
+#[cfg(not(feature = "no_std"))]
+extern crate std;
+
+extern crate alloc;
+
 extern crate array_init;
 #[allow(dead_code, unused_imports)]
 #[path = "../../arrays_test/mod.rs"]
 mod arrays_test_generated;
-use std::fmt::Debug;
+use alloc::format;
+use core::fmt::Debug;
 
 use crate::arrays_test_generated::my_game::example::*;
 extern crate quickcheck;
 use array_init::array_init;
-use std::mem::size_of;
+use core::mem::size_of;
 use quickcheck::{Arbitrary, Gen};
 
-
 fn create_serialized_example_with_generated_code(builder: &mut flatbuffers::FlatBufferBuilder) {
     let nested_struct1 = NestedStruct::new(
         &[-1, 2],
@@ -111,12 +118,12 @@
 
 #[test]
 fn struct_netsted_struct_is_32_bytes() {
-    assert_eq!(32, ::std::mem::size_of::<NestedStruct>());
+    assert_eq!(32, ::core::mem::size_of::<NestedStruct>());
 }
 
 #[test]
 fn struct_array_struct_is_160_bytes() {
-    assert_eq!(160, ::std::mem::size_of::<ArrayStruct>());
+    assert_eq!(160, ::core::mem::size_of::<ArrayStruct>());
 }
 
 #[test]
@@ -228,7 +235,7 @@
     let b_start_ptr = array_struct.b().as_ptr() as usize;
     let d_start_ptr = array_struct.d().as_ptr() as usize;
     // The T type of b
-    let b_aln = ::std::mem::align_of::<i32>();
+    let b_aln = ::core::mem::align_of::<i32>();
     assert_eq!((b_start_ptr - struct_start_ptr) % b_aln, 0);
     assert_eq!((d_start_ptr - b_start_ptr) % b_aln, 0);
     assert_eq!((d_start_ptr - struct_start_ptr) % 8, 0);
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/binary_format.rs b/tests/rust_usage_test/tests/flexbuffers_tests/binary_format.rs
index 910fc78..84fd21b 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/binary_format.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/binary_format.rs
@@ -115,7 +115,6 @@
         let mut expected = x.to_le_bytes().to_vec();
         expected.push(3 << 2 | 2);  // Float W32.
         expected.push(4); // Root width W32.
-        println!("{:?}: {:?} vs {:?} cmp {:?}", x, &fxb, &expected, fxb==expected);
         fxb == expected
     }
 }
@@ -321,7 +320,7 @@
     v.push(IndirectUInt(u64::max_value()));
     v.push(IndirectInt(i64::min_value()));
     // TODO(cneo): Something about Float EPSILON and casting leads to a different binary format.
-    v.push(IndirectFloat(std::f64::consts::PI));
+    v.push(IndirectFloat(core::f64::consts::PI));
     v.push(0u32); // This is stored in 8 bits instead of 64 because of indirection.
     v.end_vector();
     assert_eq!(
@@ -385,7 +384,6 @@
     v.push(IndirectInt(i64::max_value()));
     v.end_vector();
     let len_with_indirect = builder.view().len() as f32;
-    dbg!(len_with_indirect, len_without_indirect);
     assert!(len_with_indirect * 2.5 < len_without_indirect);
 }
 #[test]
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/mod.rs b/tests/rust_usage_test/tests/flexbuffers_tests/mod.rs
index 621f81b..ee52aca 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/mod.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/mod.rs
@@ -13,6 +13,7 @@
 // limitations under the License.
 
 mod binary_format;
+#[cfg(not(feature = "no_std"))] // uses file I/O
 mod interop;
 mod other_api;
 #[cfg(not(miri))]  // slow.
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/other_api.rs b/tests/rust_usage_test/tests/flexbuffers_tests/other_api.rs
index d1c0873..9875c22 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/other_api.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/other_api.rs
@@ -12,6 +12,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+use alloc::vec::Vec;
+
 use flexbuffers::*;
 #[cfg(not(miri))]  // slow.
 use quickcheck::QuickCheck;
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/qc_serious.rs b/tests/rust_usage_test/tests/flexbuffers_tests/qc_serious.rs
index 1bed3c2..b2e04ec 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/qc_serious.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/qc_serious.rs
@@ -1,7 +1,10 @@
+use alloc::collections::BTreeMap;
+use alloc::string::String;
+use alloc::vec::Vec;
+
 use super::rwyw::NonNullString;
 use flexbuffers::*;
 use quickcheck::{Arbitrary, Gen};
-use std::collections::BTreeMap;
 
 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
 enum Enum {
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/rwyw.rs b/tests/rust_usage_test/tests/flexbuffers_tests/rwyw.rs
index 8c27e6b..478d33a 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/rwyw.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/rwyw.rs
@@ -12,6 +12,9 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+
 // Read what you wrote.
 use flexbuffers::*;
 #[cfg(not(miri))]  // slow.
@@ -23,7 +26,7 @@
 pub struct NonNullString(String);
 impl quickcheck::Arbitrary for NonNullString {
     fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
-        let size = std::cmp::min(1, usize::arbitrary(g));
+        let size = core::cmp::min(1, usize::arbitrary(g));
         NonNullString(
             (0..)
                 .map(|_| <char>::arbitrary(g))
@@ -74,7 +77,7 @@
         }
         v.end_vector();
         let r = Reader::get_root(builder.view()).unwrap().as_vector();
-        xs.iter().enumerate().all(|(i, &x)| (r.idx(i).as_f64() - x).abs() < std::f64::EPSILON)
+        xs.iter().enumerate().all(|(i, &x)| (r.idx(i).as_f64() - x).abs() < core::f64::EPSILON)
     }
     fn qc_vec_string(xs: Vec<String>) -> bool {
         let mut builder = Builder::default();
@@ -86,6 +89,7 @@
         let r = Reader::get_root(builder.view()).unwrap().as_vector();
         xs.iter().enumerate().all(|(i, x)| (r.idx(i).as_str() == x))
     }
+    #[cfg(not(feature = "no_std"))]
     fn qc_map_int(xs: std::collections::BTreeMap<NonNullString, i64>) -> bool {
         let mut builder = Builder::default();
         let mut m = builder.start_map();
@@ -98,6 +102,7 @@
             r.idx(i).as_i64() == v && r.idx(k.0.as_str()).as_i64() == v
         })
     }
+    #[cfg(not(feature = "no_std"))]
     fn qc_map_string(xs: std::collections::BTreeMap<NonNullString, String>) -> bool {
         let mut builder = Builder::default();
         let mut m = builder.start_map();
@@ -195,7 +200,6 @@
     let foo1 = Foo::default();
     let mut s = FlexbufferSerializer::new();
     foo1.serialize(&mut s).unwrap();
-    dbg!(s.view());
     let r = Reader::get_root(s.view()).unwrap();
     let foo2 = Foo::deserialize(r).unwrap();
     assert_eq!(foo1, foo2);
diff --git a/tests/rust_usage_test/tests/integration_test.rs b/tests/rust_usage_test/tests/integration_test.rs
index 9a4c8b3..73d4a1f 100644
--- a/tests/rust_usage_test/tests/integration_test.rs
+++ b/tests/rust_usage_test/tests/integration_test.rs
@@ -15,6 +15,18 @@
  * limitations under the License.
  */
 
+#![no_std]
+
+#[cfg(not(feature = "no_std"))]
+extern crate std;
+#[cfg(not(feature = "no_std"))]
+use alloc::vec::Vec;
+
+#[macro_use]
+extern crate alloc;
+
+use alloc::string::String;
+
 #[cfg(feature = "no_std")]
 #[global_allocator]
 static ALLOCATOR: libc_alloc::LibcAlloc = libc_alloc::LibcAlloc;
@@ -392,9 +404,9 @@
     // If the verifier says a buffer is okay then using it won't cause a crash.
     // We use write_fmt since Debug visits all the fields - but there's no need to store anything.
     struct ForgetfulWriter;
-    use std::fmt::Write;
+    use core::fmt::Write;
     impl Write for ForgetfulWriter {
-        fn write_str(&mut self, _: &str) -> Result<(), std::fmt::Error> {
+        fn write_str(&mut self, _: &str) -> Result<(), core::fmt::Error> {
             Ok(())
         }
     }
@@ -442,7 +454,7 @@
     let b = &mut flatbuffers::FlatBufferBuilder::new();
     let name = Some(b.create_string("foo"));
     // String amplification attack.
-    let s = b.create_string(&(std::iter::repeat("X").take(1000).collect::<String>()));
+    let s = b.create_string(&(core::iter::repeat("X").take(1000).collect::<String>()));
     let testarrayofstring = Some(b.create_vector(&vec![s; 1000]));
     let m = Monster::create(b, &MonsterArgs {
         testarrayofstring,
@@ -541,11 +553,12 @@
     }
 }
 
+#[cfg(not(feature = "no_std"))]
 #[cfg(test)]
 mod lifetime_correctness {
     extern crate flatbuffers;
 
-    use std::mem;
+    use core::mem;
 
     use super::my_game;
     use super::load_file;
@@ -593,6 +606,8 @@
 mod roundtrip_generated_code {
     extern crate flatbuffers;
 
+    use alloc::vec::Vec;
+
     use super::my_game;
 
     fn build_mon<'a, 'b>(builder: &'a mut flatbuffers::FlatBufferBuilder, args: &'b my_game::example::MonsterArgs) -> my_game::example::Monster<'a> {
@@ -988,25 +1003,25 @@
 
     #[test]
     fn enum_color_is_1_byte() {
-        assert_eq!(1, ::std::mem::size_of::<my_game::example::Color>());
+        assert_eq!(1, ::core::mem::size_of::<my_game::example::Color>());
     }
 
     #[test]
     fn union_any_is_1_byte() {
-        assert_eq!(1, ::std::mem::size_of::<my_game::example::Any>());
+        assert_eq!(1, ::core::mem::size_of::<my_game::example::Any>());
     }
 
     #[test]
     fn union_any_is_aligned_to_1() {
-        assert_eq!(1, ::std::mem::align_of::<my_game::example::Any>());
+        assert_eq!(1, ::core::mem::align_of::<my_game::example::Any>());
     }
     #[test]
     fn struct_test_is_4_bytes() {
-        assert_eq!(4, ::std::mem::size_of::<my_game::example::Test>());
+        assert_eq!(4, ::core::mem::size_of::<my_game::example::Test>());
     }
     #[test]
     fn struct_vec3_is_32_bytes() {
-        assert_eq!(32, ::std::mem::size_of::<my_game::example::Vec3>());
+        assert_eq!(32, ::core::mem::size_of::<my_game::example::Vec3>());
     }
 
     #[test]
@@ -1036,7 +1051,7 @@
 
     #[test]
     fn struct_ability_is_8_bytes() {
-        assert_eq!(8, ::std::mem::size_of::<my_game::example::Ability>());
+        assert_eq!(8, ::core::mem::size_of::<my_game::example::Ability>());
     }
 
     #[test]
@@ -1061,7 +1076,7 @@
         for a in abilities.iter() {
             let a_ptr = a as *const my_game::example::Ability as usize;
             assert!(a_ptr > start_ptr);
-            let aln = ::std::mem::align_of::<my_game::example::Ability>();
+            let aln = ::core::mem::align_of::<my_game::example::Ability>();
             assert_eq!((a_ptr - start_ptr) % aln, 0);
         }
         for a in abilities.iter().rev() {
@@ -1166,6 +1181,8 @@
         extern crate quickcheck;
         extern crate flatbuffers;
 
+        use alloc::vec::Vec;
+
         const N: u64 = 20;
 
         fn prop<T>(xs: Vec<T>)
@@ -1173,7 +1190,7 @@
             T: for<'a> flatbuffers::Follow<'a, Inner = T>
                 + flatbuffers::EndianScalar
                 + flatbuffers::Push
-                + ::std::fmt::Debug,
+                + ::core::fmt::Debug,
         {
             use flatbuffers::Follow;
 
@@ -1247,7 +1264,7 @@
         // complicated.
         macro_rules! impl_prop {
             ($test_name:ident, $fn_name:ident, $ty:ident) => (
-                fn $fn_name(xs: Vec<$ty>) {
+                fn $fn_name(xs: alloc::vec::Vec<$ty>) {
                     use flatbuffers::Follow;
 
                     let mut b = flatbuffers::FlatBufferBuilder::new();
@@ -1258,7 +1275,7 @@
                     assert_eq!(got, &xs[..]);
                 }
                 #[test]
-                fn $test_name() { quickcheck::QuickCheck::new().max_tests(N).quickcheck($fn_name as fn(Vec<_>)); }
+                fn $test_name() { quickcheck::QuickCheck::new().max_tests(N).quickcheck($fn_name as fn(alloc::vec::Vec<_>)); }
             )
         }
 
@@ -1289,6 +1306,9 @@
         extern crate quickcheck;
         extern crate flatbuffers;
 
+        use alloc::string::String;
+        use alloc::vec::Vec;
+
         fn prop(xs: Vec<String>) {
             use flatbuffers::Follow;
 
@@ -1327,6 +1347,9 @@
         extern crate quickcheck;
         extern crate flatbuffers;
 
+        use alloc::string::String;
+        use alloc::vec::Vec;
+
         fn prop(input: Vec<String>) {
             let xs: Vec<&str> = input.iter().map(|s: &String| &s[..]).collect();
 
@@ -1358,6 +1381,8 @@
         extern crate quickcheck;
         extern crate flatbuffers;
 
+        use alloc::vec::Vec;
+
         #[cfg(not(miri))]  // slow.
         #[test]
         fn fuzz_manual_build() {
@@ -1409,8 +1434,11 @@
     }
 }
 
+#[cfg(not(feature = "no_std"))]
 #[cfg(test)]
 mod roundtrip_table {
+    use alloc::string::String;
+    use alloc::vec::Vec;
     use std::collections::HashMap;
 
     extern crate flatbuffers;
@@ -1429,9 +1457,9 @@
         let uchar_val: u8 = 0xFF;
         let short_val: i16 = -32222;  // 0x8222;
         let ushort_val: u16 = 0xFEEE;
-        let int_val: i32 = unsafe { ::std::mem::transmute(0x83333333u32) };
+        let int_val: i32 = unsafe { ::core::mem::transmute(0x83333333u32) };
         let uint_val: u32 = 0xFDDDDDDD;
-        let long_val: i64 = unsafe { ::std::mem::transmute(0x8444444444444444u64) }; // TODO: byte literal?
+        let long_val: i64 = unsafe { ::core::mem::transmute(0x8444444444444444u64) }; // TODO: byte literal?
         let ulong_val: u64 = 0xFCCCCCCCCCCCCCCCu64;
         let float_val: f32 = 3.14159;
         let double_val: f64 = 3.14159265359;
@@ -1598,6 +1626,9 @@
 
     #[cfg(not(miri))]  // slow.
     mod table_of_vectors_of_scalars {
+
+        use alloc::vec::Vec;
+
         extern crate flatbuffers;
         #[cfg(not(miri))]  // slow.
         extern crate quickcheck;
@@ -1609,7 +1640,7 @@
             T: for<'a> flatbuffers::Follow<'a, Inner = T>
                 + flatbuffers::EndianScalar
                 + flatbuffers::Push
-                + ::std::fmt::Debug,
+                + ::core::fmt::Debug,
         {
             use flatbuffers::field_index_to_field_offset as fi2fo;
             use flatbuffers::Follow;
@@ -1689,8 +1720,8 @@
 
     const N: u64 = 1000;
 
-    fn prop<T: PartialEq + ::std::fmt::Debug + Copy + flatbuffers::EndianScalar>(x: T) {
-        let mut buf = vec![0u8; ::std::mem::size_of::<T>()];
+    fn prop<T: PartialEq + ::core::fmt::Debug + Copy + flatbuffers::EndianScalar>(x: T) {
+        let mut buf = vec![0u8; ::core::mem::size_of::<T>()];
         let y = unsafe {
             flatbuffers::emplace_scalar(&mut buf[..], x);
             flatbuffers::read_scalar(&buf[..])
@@ -1742,7 +1773,7 @@
     macro_rules! impl_prop {
         ($fn_name:ident, $ty:ident) => (
             fn $fn_name(x: $ty) {
-                let mut buf = vec![0u8; ::std::mem::size_of::<$ty>()];
+                let mut buf = vec![0u8; ::core::mem::size_of::<$ty>()];
                 x.push(&mut buf[..], &[][..]);
                 let fs: flatbuffers::FollowStart<$ty> = flatbuffers::FollowStart::new();
                 assert_eq!(fs.self_follow(&buf[..], 0), x);
@@ -1896,10 +1927,13 @@
     }
 }
 
+#[cfg(not(feature = "no_std"))]
 #[cfg(test)]
 mod read_examples_from_other_language_ports {
     extern crate flatbuffers;
 
+    use std::println;
+
     use super::load_file;
     use super::serialized_example_is_accessible_and_correct;
 
@@ -1974,9 +2008,9 @@
     fn struct_key_compare_with_value() {
         let a = my_game::example::Ability::new(1, 2);
 
-        assert_eq!(a.key_compare_with_value(0), ::std::cmp::Ordering::Greater);
-        assert_eq!(a.key_compare_with_value(1), ::std::cmp::Ordering::Equal);
-        assert_eq!(a.key_compare_with_value(2), ::std::cmp::Ordering::Less);
+        assert_eq!(a.key_compare_with_value(0), ::core::cmp::Ordering::Greater);
+        assert_eq!(a.key_compare_with_value(1), ::core::cmp::Ordering::Equal);
+        assert_eq!(a.key_compare_with_value(2), ::core::cmp::Ordering::Less);
     }
 
     #[test]
@@ -2010,9 +2044,9 @@
         // preconditions
         assert_eq!(a.name(), "MyMonster");
 
-        assert_eq!(a.key_compare_with_value("AAA"), ::std::cmp::Ordering::Greater);
-        assert_eq!(a.key_compare_with_value("MyMonster"), ::std::cmp::Ordering::Equal);
-        assert_eq!(a.key_compare_with_value("ZZZ"), ::std::cmp::Ordering::Less);
+        assert_eq!(a.key_compare_with_value("AAA"), ::core::cmp::Ordering::Greater);
+        assert_eq!(a.key_compare_with_value("MyMonster"), ::core::cmp::Ordering::Equal);
+        assert_eq!(a.key_compare_with_value("ZZZ"), ::core::cmp::Ordering::Less);
     }
 
     #[test]
@@ -2116,6 +2150,8 @@
     use flatbuffers::Follow;
     use flatbuffers::field_index_to_field_offset as fi2fo;
 
+    use alloc::vec::Vec;
+
     // Define a test struct to use in a few tests. This replicates the work that the code generator
     // would normally do when defining a FlatBuffer struct. For reference, compare the following
     // `FooStruct` code with the code generated for the `Vec3` struct in
@@ -2884,12 +2920,12 @@
             c: i8,
             _pad2: [u8; 4],
         }
-        assert_eq!(::std::mem::size_of::<foo>(), 16);
+        assert_eq!(::core::mem::size_of::<foo>(), 16);
         impl<'b> flatbuffers::Push for &'b foo {
             type Output = foo;
             fn push<'a>(&'a self, dst: &'a mut [u8], _rest: &'a [u8]) {
                 let src = unsafe {
-                    ::std::slice::from_raw_parts(*self as *const foo as *const u8, ::std::mem::size_of::<foo>())
+                    ::core::slice::from_raw_parts(*self as *const foo as *const u8, ::core::mem::size_of::<foo>())
                 };
                 dst.copy_from_slice(src);
             }
@@ -3170,6 +3206,9 @@
 
 #[cfg(test)]
 mod copy_clone_traits {
+
+    use alloc::vec::Vec;
+
     #[test]
     fn follow_types_implement_copy_and_clone() {
         static_assertions::assert_impl_all!(flatbuffers::WIPOffset<u32>: Copy, Clone);
@@ -3187,17 +3226,18 @@
 mod fully_qualified_name {
     #[test]
     fn fully_qualified_name_generated() {
-        assert!(check_eq!(::my_game::example::Monster::get_fully_qualified_name(), "MyGame.Example.Monster").is_ok());
-        assert!(check_eq!(::my_game::example_2::Monster::get_fully_qualified_name(), "MyGame.Example2.Monster").is_ok());
+        assert!(check_eq!(super::my_game::example::Monster::get_fully_qualified_name(), "MyGame.Example.Monster").is_ok());
+        assert!(check_eq!(super::my_game::example_2::Monster::get_fully_qualified_name(), "MyGame.Example2.Monster").is_ok());
 
-        assert!(check_eq!(::my_game::example::Vec3::get_fully_qualified_name(), "MyGame.Example.Vec3").is_ok());
-        assert!(check_eq!(::my_game::example::Ability::get_fully_qualified_name(), "MyGame.Example.Ability").is_ok());
+        assert!(check_eq!(super::my_game::example::Vec3::get_fully_qualified_name(), "MyGame.Example.Vec3").is_ok());
+        assert!(check_eq!(super::my_game::example::Ability::get_fully_qualified_name(), "MyGame.Example.Ability").is_ok());
     }
 }
 
 // this is not technically a test, but we want to always keep this generated
 // file up-to-date, and the simplest way to do that is to make sure that when
 // tests are run, the file is generated.
+#[cfg(not(feature = "no_std"))]
 #[test]
 fn write_example_wire_data_to_file() {
     let b = &mut flatbuffers::FlatBufferBuilder::new();
@@ -3208,6 +3248,7 @@
     f.write_all(b.finished_data()).unwrap();
 }
 
+#[cfg(not(feature = "no_std"))]
 fn load_file(filename: &str) -> Result<Vec<u8>, std::io::Error> {
     use std::io::Read;
     let mut f = std::fs::File::open(filename)?;
diff --git a/tests/rust_usage_test/tests/more_defaults_test.rs b/tests/rust_usage_test/tests/more_defaults_test.rs
index af664f2..4d62a4a 100644
--- a/tests/rust_usage_test/tests/more_defaults_test.rs
+++ b/tests/rust_usage_test/tests/more_defaults_test.rs
@@ -1,3 +1,8 @@
+extern crate alloc;
+
+use alloc::string::ToString;
+use alloc::vec::Vec;
+
 #[allow(dead_code, unused_imports)]
 #[path = "../../more_defaults/mod.rs"]
 mod more_defaults_generated;