diff --git a/samples/rust_generated/my_game/sample/color_generated.rs b/samples/rust_generated/my_game/sample/color_generated.rs index 1ef1d31b5..ed1440d1d 100644 --- a/samples/rust_generated/my_game/sample/color_generated.rs +++ b/samples/rust_generated/my_game/sample/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::*; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] @@ -42,8 +46,8 @@ impl Color { } } } -impl std::fmt::Debug for Color { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { +impl core::fmt::Debug for Color { + 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/samples/rust_generated/my_game/sample/equipment_generated.rs b/samples/rust_generated/my_game/sample/equipment_generated.rs index 919958a35..8eb5a1654 100644 --- a/samples/rust_generated/my_game/sample/equipment_generated.rs +++ b/samples/rust_generated/my_game/sample/equipment_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 Equipment { } } } -impl std::fmt::Debug for Equipment { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { +impl core::fmt::Debug for Equipment { + 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 @@ impl EquipmentT { /// If the union variant matches, return the owned WeaponT, setting the union to NONE. pub fn take_weapon(&mut self) -> Option> { if let Self::Weapon(_) = self { - let v = std::mem::replace(self, Self::NONE); + let v = core::mem::replace(self, Self::NONE); if let Self::Weapon(w) = v { Some(w) } else { diff --git a/samples/rust_generated/my_game/sample/monster_generated.rs b/samples/rust_generated/my_game/sample/monster_generated.rs index c156225f0..ee444f069 100644 --- a/samples/rust_generated/my_game/sample/monster_generated.rs +++ b/samples/rust_generated/my_game/sample/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 {} @@ -266,8 +270,8 @@ impl<'a: 'b, 'b> MonsterBuilder<'a, 'b> { } } -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/samples/rust_generated/my_game/sample/vec_3_generated.rs b/samples/rust_generated/my_game/sample/vec_3_generated.rs index a1647d5d3..9d889702d 100644 --- a/samples/rust_generated/my_game/sample/vec_3_generated.rs +++ b/samples/rust_generated/my_game/sample/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 4 @@ -13,8 +17,8 @@ impl Default for Vec3 { Self([0; 12]) } } -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()) @@ -44,7 +48,7 @@ impl<'b> flatbuffers::Push for Vec3 { #[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); } @@ -55,7 +59,7 @@ impl<'b> flatbuffers::Push for &'b Vec3 { #[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/samples/rust_generated/my_game/sample/weapon_generated.rs b/samples/rust_generated/my_game/sample/weapon_generated.rs index 50a678b6e..f2802bb0a 100644 --- a/samples/rust_generated/my_game/sample/weapon_generated.rs +++ b/samples/rust_generated/my_game/sample/weapon_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 WeaponOffset {} @@ -118,8 +122,8 @@ impl<'a: 'b, 'b> WeaponBuilder<'a, 'b> { } } -impl std::fmt::Debug for Weapon<'_> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl core::fmt::Debug for Weapon<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Weapon"); ds.field("name", &self.name()); ds.field("damage", &self.damage()); diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp index 52299cd85..571b70a92 100644 --- a/src/idl_gen_rust.cpp +++ b/src/idl_gen_rust.cpp @@ -367,9 +367,13 @@ class RustGenerator : public BaseGenerator { if (symbol.generated) continue; code_.Clear(); code_ += "// " + std::string(FlatBuffersGeneratedWarning()); + code_ += "extern crate alloc;"; code_ += "extern crate flatbuffers;"; - code_ += "use std::mem;"; - code_ += "use std::cmp::Ordering;"; + code_ += "use alloc::boxed::Box;"; + code_ += "use alloc::string::{String, ToString};"; + code_ += "use alloc::vec::Vec;"; + code_ += "use core::mem;"; + code_ += "use core::cmp::Ordering;"; if (parser_.opts.rust_serialize) { code_ += "extern crate serde;"; code_ += @@ -786,10 +790,10 @@ class RustGenerator : public BaseGenerator { code_ += "}"; // Generate Debug. Unknown variants are printed like "". - code_ += "impl std::fmt::Debug for {{ENUM_TY}} {"; + code_ += "impl core::fmt::Debug for {{ENUM_TY}} {"; code_ += - " fn fmt(&self, f: &mut std::fmt::Formatter) ->" - " std::fmt::Result {"; + " fn fmt(&self, f: &mut core::fmt::Formatter) ->" + " core::fmt::Result {"; code_ += " if let Some(name) = self.variant_name() {"; code_ += " f.write_str(name)"; code_ += " } else {"; @@ -964,7 +968,7 @@ class RustGenerator : public BaseGenerator { "pub fn take_{{U_ELEMENT_NAME}}(&mut self) -> " "Option> {"; code_ += " if let Self::{{NATIVE_VARIANT}}(_) = self {"; - code_ += " let v = std::mem::replace(self, Self::NONE);"; + code_ += " let v = core::mem::replace(self, Self::NONE);"; code_ += " if let Self::{{NATIVE_VARIANT}}(w) = v {"; code_ += " Some(w)"; code_ += " } else {"; @@ -2121,10 +2125,10 @@ class RustGenerator : public BaseGenerator { code_ += "}"; code_ += ""; - code_ += "impl std::fmt::Debug for {{STRUCT_TY}}<'_> {"; + code_ += "impl core::fmt::Debug for {{STRUCT_TY}}<'_> {"; code_ += - " fn fmt(&self, f: &mut std::fmt::Formatter<'_>" - ") -> std::fmt::Result {"; + " fn fmt(&self, f: &mut core::fmt::Formatter<'_>" + ") -> core::fmt::Result {"; code_ += " let mut ds = f.debug_struct(\"{{STRUCT_TY}}\");"; ForAllTableFields(struct_def, [&](const FieldDef &field) { if (GetFullType(field.value.type) == ftUnionValue) { @@ -2344,7 +2348,7 @@ class RustGenerator : public BaseGenerator { code_ += "#[inline]"; code_ += "pub fn key_compare_with_value(&self, val: {{KEY_TYPE}}) -> " - "::std::cmp::Ordering {"; + "::core::cmp::Ordering {"; code_ += " let key = self.{{FIELD}}();"; code_ += " key.cmp({{REF}}val)"; code_ += "}"; @@ -2604,10 +2608,10 @@ class RustGenerator : public BaseGenerator { code_ += "}"; // Debug for structs. - code_ += "impl std::fmt::Debug for {{STRUCT_TY}} {"; + code_ += "impl core::fmt::Debug for {{STRUCT_TY}} {"; code_ += - " fn fmt(&self, f: &mut std::fmt::Formatter" - ") -> std::fmt::Result {"; + " fn fmt(&self, f: &mut core::fmt::Formatter" + ") -> core::fmt::Result {"; code_ += " f.debug_struct(\"{{STRUCT_TY}}\")"; ForAllStructFields(struct_def, [&](const FieldDef &unused) { (void)unused; @@ -2643,7 +2647,7 @@ class RustGenerator : public BaseGenerator { code_ += " fn push(&self, dst: &mut [u8], _rest: &[u8]) {"; code_ += " let src = unsafe {"; code_ += - " ::std::slice::from_raw_parts(" + " ::core::slice::from_raw_parts(" "self as *const {{STRUCT_TY}} as *const u8, Self::size())"; code_ += " };"; code_ += " dst.copy_from_slice(src);"; @@ -2656,7 +2660,7 @@ class RustGenerator : public BaseGenerator { code_ += " fn push(&self, dst: &mut [u8], _rest: &[u8]) {"; code_ += " let src = unsafe {"; code_ += - " ::std::slice::from_raw_parts(" + " ::core::slice::from_raw_parts(" "*self as *const {{STRUCT_TY}} as *const u8, Self::size())"; code_ += " };"; code_ += " dst.copy_from_slice(src);"; @@ -2788,7 +2792,7 @@ class RustGenerator : public BaseGenerator { NumToString(InlineSize(field.value.type))); code_ += "pub fn set_{{FIELD}}(&mut self, x: &{{FIELD_TYPE}}) {"; code_ += " unsafe {"; - code_ += " std::ptr::copy("; + code_ += " core::ptr::copy("; code_ += " x.as_ptr() as *const u8,"; code_ += " self.0.as_mut_ptr().add({{FIELD_OFFSET}}),"; code_ += " {{FIELD_SIZE}},"; @@ -2901,8 +2905,8 @@ class RustGenerator : public BaseGenerator { } } } - code_ += indent + "use std::mem;"; - code_ += indent + "use std::cmp::Ordering;"; + code_ += indent + "use core::mem;"; + code_ += indent + "use core::cmp::Ordering;"; code_ += ""; if (parser_.opts.rust_serialize) { code_ += indent + "extern crate serde;"; 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 dea3655a3..3261f12a9 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 @@ impl Default for ArrayStruct { 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 @@ impl<'b> flatbuffers::Push for ArrayStruct { #[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 @@ impl<'b> flatbuffers::Push for &'b ArrayStruct { #[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 @@ impl<'a> ArrayStruct { 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 f46ac7478..87cf6b77d 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<'a: 'b, 'b> ArrayTableBuilder<'a, 'b> { } } -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 48a6b91f0..9d841c70c 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 @@ impl Default for NestedStruct { 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 @@ impl<'b> flatbuffers::Push for NestedStruct { #[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 @@ impl<'b> flatbuffers::Push for &'b NestedStruct { #[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 @@ impl<'a> NestedStruct { 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 6dcc1cb97..38a4696eb 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 TestEnum { } } } -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 048bafdb8..54be3d608 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 FromInclude { } } } -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 46a99cb0d..edb14bc98 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<'a: 'b, 'b> TableBBuilder<'a, 'b> { } } -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 1dc5913e7..d0b3f3a34 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 @@ impl Default for Unused { 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 @@ impl<'b> flatbuffers::Push for Unused { #[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 @@ impl<'b> flatbuffers::Push for &'b Unused { #[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 9188b293f..512344533 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<'a: 'b, 'b> TableABuilder<'a, 'b> { } } -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 048bafdb8..54be3d608 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 FromInclude { } } } -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 46a99cb0d..edb14bc98 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<'a: 'b, 'b> TableBBuilder<'a, 'b> { } } -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 1dc5913e7..d0b3f3a34 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 @@ impl Default for Unused { 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 @@ impl<'b> flatbuffers::Push for Unused { #[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 @@ impl<'b> flatbuffers::Push for &'b Unused { #[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 9188b293f..512344533 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<'a: 'b, 'b> TableABuilder<'a, 'b> { } } -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 99b43e466..39dc188e1 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 ABC { } } } -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 0790048d3..0b9939b91 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<'a: 'b, 'b> KeywordsInTableBuilder<'a, 'b> { } } -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 cf03797f9..65df3fe79 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 KeywordsInUnion { } } } -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 @@ impl KeywordsInUnionT { /// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE. pub fn take_static_(&mut self) -> Option> { 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 @@ impl KeywordsInUnionT { /// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE. pub fn take_internal(&mut self) -> Option> { 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 2de4c0b24..e2befd34f 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 public { } } } -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 5746e8e96..8c23c11b3 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 @@ impl Default for Ability { 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 @@ impl<'b> flatbuffers::Push for Ability { #[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 @@ impl<'b> flatbuffers::Push for &'b Ability { #[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 @@ impl<'a> Ability { } #[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 321007abe..32e31eeeb 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 AnyAmbiguousAliases { } } } -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 @@ impl AnyAmbiguousAliasesT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_m1(&mut self) -> Option> { 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 @@ impl AnyAmbiguousAliasesT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_m2(&mut self) -> Option> { 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 @@ impl AnyAmbiguousAliasesT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_m3(&mut self) -> Option> { 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 6f7f6fdac..4008dc090 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 Any { } } } -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 @@ impl AnyT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_monster(&mut self) -> Option> { 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 @@ impl AnyT { /// 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> { 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 @@ impl AnyT { /// 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> { 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 1749d5d7a..1337a2989 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 AnyUniqueAliases { } } } -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 @@ impl AnyUniqueAliasesT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_m(&mut self) -> Option> { 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 @@ impl AnyUniqueAliasesT { /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE. pub fn take_ts(&mut self) -> Option> { 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 @@ impl AnyUniqueAliasesT { /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE. pub fn take_m2(&mut self) -> Option> { 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 4a3282b46..2679798cc 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 b22f82693..7844af5b4 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 58e762859..cf1b33c3d 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 @@ impl<'a> Monster<'a> { } #[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<'a: 'b, 'b> MonsterBuilder<'a, 'b> { } } -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 ab012f9bf..a2a159375 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 Race { } } } -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 877e3b838..0395ab298 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 @@ impl<'a> Referrable<'a> { } #[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<'a: 'b, 'b> ReferrableBuilder<'a, 'b> { } } -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 d6e5fad56..b939f1911 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 @@ impl<'a> Stat<'a> { } #[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<'a: 'b, 'b> StatBuilder<'a, 'b> { } } -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 9994f7e32..9747e0c15 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 @@ impl Default for StructOfStructs { 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 @@ impl<'b> flatbuffers::Push for StructOfStructs { #[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 @@ impl<'b> flatbuffers::Push for &'b StructOfStructs { #[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 9a92dd13f..b2d22b7ef 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 @@ impl Default for StructOfStructsOfStructs { 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 @@ impl<'b> flatbuffers::Push for StructOfStructsOfStructs { #[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 @@ impl<'b> flatbuffers::Push for &'b StructOfStructsOfStructs { #[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 187b7cd6d..7d9885c40 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 @@ impl Default for Test { 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 @@ impl<'b> flatbuffers::Push for Test { #[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 @@ impl<'b> flatbuffers::Push for &'b Test { #[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 6ebe31fcd..0e3c71737 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<'a: 'b, 'b> TestSimpleTableWithEnumBuilder<'a, 'b> { } } -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 5b3ede58b..f232d3e5d 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<'a: 'b, 'b> TypeAliasesBuilder<'a, 'b> { } } -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 e5a25bbfa..736bf3529 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 @@ impl Default for Vec3 { 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 @@ impl<'b> flatbuffers::Push for Vec3 { #[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 @@ impl<'b> flatbuffers::Push for &'b Vec3 { #[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 54384b500..8925b5a75 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<'a: 'b, 'b> MonsterBuilder<'a, 'b> { } } -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 aabd4b836..216dfa3e0 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<'a: 'b, 'b> InParentNamespaceBuilder<'a, 'b> { } } -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 048bafdb8..54be3d608 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 FromInclude { } } } -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 46a99cb0d..edb14bc98 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<'a: 'b, 'b> TableBBuilder<'a, 'b> { } } -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 1dc5913e7..d0b3f3a34 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 @@ impl Default for Unused { 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 @@ impl<'b> flatbuffers::Push for Unused { #[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 @@ impl<'b> flatbuffers::Push for &'b Unused { #[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 9188b293f..512344533 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<'a: 'b, 'b> TableABuilder<'a, 'b> { } } -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 cdc788257..a0fc73c6a 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 @@ impl Default for Ability { 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 @@ impl<'b> flatbuffers::Push for Ability { #[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 @@ impl<'b> flatbuffers::Push for &'b Ability { #[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 @@ impl<'a> Ability { } #[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 2e757a804..988536363 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 AnyAmbiguousAliases { } } } -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 @@ impl AnyAmbiguousAliasesT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_m1(&mut self) -> Option> { 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 @@ impl AnyAmbiguousAliasesT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_m2(&mut self) -> Option> { 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 @@ impl AnyAmbiguousAliasesT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_m3(&mut self) -> Option> { 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 d5726428a..1af99de8f 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 Any { } } } -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 @@ impl AnyT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_monster(&mut self) -> Option> { 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 @@ impl AnyT { /// 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> { 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 @@ impl AnyT { /// 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> { 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 8a3fa66de..a6897dd02 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 AnyUniqueAliases { } } } -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 @@ impl AnyUniqueAliasesT { /// If the union variant matches, return the owned MonsterT, setting the union to NONE. pub fn take_m(&mut self) -> Option> { 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 @@ impl AnyUniqueAliasesT { /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE. pub fn take_ts(&mut self) -> Option> { 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 @@ impl AnyUniqueAliasesT { /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE. pub fn take_m2(&mut self) -> Option> { 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 e27f79cab..cf6b78e9e 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 f513d29b3..16b29b4d8 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 cd5730f5b..c6aa81b6d 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 @@ impl<'a> Monster<'a> { } #[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<'a: 'b, 'b> MonsterBuilder<'a, 'b> { } } -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 63754ff97..4fddd6416 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 Race { } } } -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 490980d01..72543fa72 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 @@ impl<'a> Referrable<'a> { } #[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<'a: 'b, 'b> ReferrableBuilder<'a, 'b> { } } -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 abfa05d1b..38e10a998 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 @@ impl<'a> Stat<'a> { } #[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<'a: 'b, 'b> StatBuilder<'a, 'b> { } } -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 75b8865c3..5a7eb5a50 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 @@ impl Default for StructOfStructs { 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 @@ impl<'b> flatbuffers::Push for StructOfStructs { #[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 @@ impl<'b> flatbuffers::Push for &'b StructOfStructs { #[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 9bf2ea261..d6acf9de3 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 @@ impl Default for StructOfStructsOfStructs { 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 @@ impl<'b> flatbuffers::Push for StructOfStructsOfStructs { #[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 @@ impl<'b> flatbuffers::Push for &'b StructOfStructsOfStructs { #[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 56493ba15..c5e5132e5 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 @@ impl Default for Test { 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 @@ impl<'b> flatbuffers::Push for Test { #[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 @@ impl<'b> flatbuffers::Push for &'b Test { #[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 cd643118f..b9dce52e0 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<'a: 'b, 'b> TestSimpleTableWithEnumBuilder<'a, 'b> { } } -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 44d11983c..2a8d52a73 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<'a: 'b, 'b> TypeAliasesBuilder<'a, 'b> { } } -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 f04d0e8f0..34190896b 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 @@ impl Default for Vec3 { 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 @@ impl<'b> flatbuffers::Push for Vec3 { #[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 @@ impl<'b> flatbuffers::Push for &'b Vec3 { #[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 7687c5e96..627278bb9 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<'a: 'b, 'b> MonsterBuilder<'a, 'b> { } } -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 b2b0a095e..4d61f4080 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<'a: 'b, 'b> InParentNamespaceBuilder<'a, 'b> { } } -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 06a0fa867..d1440f5aa 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 FromInclude { } } } -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 f09e17588..6af0c32e5 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<'a: 'b, 'b> TableBBuilder<'a, 'b> { } } -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 7b91447d3..bf35e72d9 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 @@ impl Default for Unused { 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 @@ impl<'b> flatbuffers::Push for Unused { #[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 @@ impl<'b> flatbuffers::Push for &'b Unused { #[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 eb03f4966..9ee3747c6 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<'a: 'b, 'b> TableABuilder<'a, 'b> { } } -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 8622d9ba1..42f716b89 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 ABC { } } } -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 0a8810559..7de58f6ea 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<'a: 'b, 'b> MoreDefaultsBuilder<'a, 'b> { } } -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 b6366385a..5e595222e 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 EnumInNestedNS { } } } -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 55fff40e7..b26afe8e5 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 @@ impl Default for StructInNestedNS { 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 @@ impl<'b> flatbuffers::Push for StructInNestedNS { #[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 @@ impl<'b> flatbuffers::Push for &'b StructInNestedNS { #[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 10d5b7cbf..f8054e8a3 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<'a: 'b, 'b> TableInNestedNSBuilder<'a, 'b> { } } -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 8d650a513..1758f88f5 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 UnionInNestedNS { } } } -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 @@ impl UnionInNestedNST { /// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE. pub fn take_table_in_nested_ns(&mut self) -> Option> { 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 d63438b64..91561b973 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<'a: 'b, 'b> SecondTableInABuilder<'a, 'b> { } } -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 0a16074ab..5a76dbd59 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<'a: 'b, 'b> TableInFirstNSBuilder<'a, 'b> { } } -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 d4ac7837b..6d548cf87 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<'a: 'b, 'b> TableInCBuilder<'a, 'b> { } } -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 226e9ecef..b57053d8d 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 OptionalByte { } } } -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 407e278f8..bc5375af7 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<'a: 'b, 'b> ScalarStuffBuilder<'a, 'b> { } } -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 e676970ea..d5731e7d2 100644 --- a/tests/rust_usage_test/Cargo.toml +++ b/tests/rust_usage_test/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" authors = ["Robert Winslow ", "Casper Neo ", "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 580d4336c..7d7250181 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 1b9a8fbba..26842910b 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 faa0ac8d2..e92e86245 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 @@ fn generated_code_creates_correct_example() { #[test] fn struct_netsted_struct_is_32_bytes() { - assert_eq!(32, ::std::mem::size_of::()); + assert_eq!(32, ::core::mem::size_of::()); } #[test] fn struct_array_struct_is_160_bytes() { - assert_eq!(160, ::std::mem::size_of::()); + assert_eq!(160, ::core::mem::size_of::()); } #[test] @@ -228,7 +235,7 @@ fn verify_struct_array_alignment() { 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::(); + let b_aln = ::core::mem::align_of::(); 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 910fc7881..84fd21be2 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 @@ quickcheck! { 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 @@ fn indirect_numbers() { 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 @@ fn indirect_2p5x_smaller() { 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 621f81bb5..ee52aca30 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 d1c0873bb..9875c2282 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 1bed3c2cb..b2e04ecfd 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 8c27e6bcd..478d33aef 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 @@ use serde::{Deserialize, Serialize}; pub struct NonNullString(String); impl quickcheck::Arbitrary for NonNullString { fn arbitrary(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(|_| ::arbitrary(g)) @@ -74,7 +77,7 @@ quickcheck! { } 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) -> bool { let mut builder = Builder::default(); @@ -86,6 +89,7 @@ quickcheck! { 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) -> bool { let mut builder = Builder::default(); let mut m = builder.start_map(); @@ -98,6 +102,7 @@ quickcheck! { 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) -> bool { let mut builder = Builder::default(); let mut m = builder.start_map(); @@ -195,7 +200,6 @@ fn empty_vectors() { 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 9a4c8b3a3..73d4a1f37 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 @@ fn verifier_one_byte_errors_do_not_crash() { // 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 @@ fn verifier_apparent_size_too_large() { 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::())); + let s = b.create_string(&(core::iter::repeat("X").take(1000).collect::())); let testarrayofstring = Some(b.create_vector(&vec![s; 1000])); let m = Monster::create(b, &MonsterArgs { testarrayofstring, @@ -541,11 +553,12 @@ mod generated_constants { } } +#[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 lifetime_correctness { 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 @@ mod generated_code_alignment_and_padding { #[test] fn enum_color_is_1_byte() { - assert_eq!(1, ::std::mem::size_of::()); + assert_eq!(1, ::core::mem::size_of::()); } #[test] fn union_any_is_1_byte() { - assert_eq!(1, ::std::mem::size_of::()); + assert_eq!(1, ::core::mem::size_of::()); } #[test] fn union_any_is_aligned_to_1() { - assert_eq!(1, ::std::mem::align_of::()); + assert_eq!(1, ::core::mem::align_of::()); } #[test] fn struct_test_is_4_bytes() { - assert_eq!(4, ::std::mem::size_of::()); + assert_eq!(4, ::core::mem::size_of::()); } #[test] fn struct_vec3_is_32_bytes() { - assert_eq!(32, ::std::mem::size_of::()); + assert_eq!(32, ::core::mem::size_of::()); } #[test] @@ -1036,7 +1051,7 @@ mod generated_code_alignment_and_padding { #[test] fn struct_ability_is_8_bytes() { - assert_eq!(8, ::std::mem::size_of::()); + assert_eq!(8, ::core::mem::size_of::()); } #[test] @@ -1061,7 +1076,7 @@ mod generated_code_alignment_and_padding { 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::(); + let aln = ::core::mem::align_of::(); assert_eq!((a_ptr - start_ptr) % aln, 0); } for a in abilities.iter().rev() { @@ -1166,6 +1181,8 @@ mod roundtrip_vectors { extern crate quickcheck; extern crate flatbuffers; + use alloc::vec::Vec; + const N: u64 = 20; fn prop(xs: Vec) @@ -1173,7 +1190,7 @@ mod roundtrip_vectors { 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 @@ mod roundtrip_vectors { // 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 @@ mod roundtrip_vectors { 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 @@ mod roundtrip_vectors { extern crate quickcheck; extern crate flatbuffers; + use alloc::string::String; + use alloc::vec::Vec; + fn prop(xs: Vec) { use flatbuffers::Follow; @@ -1327,6 +1347,9 @@ mod roundtrip_vectors { extern crate quickcheck; extern crate flatbuffers; + use alloc::string::String; + use alloc::vec::Vec; + fn prop(input: Vec) { let xs: Vec<&str> = input.iter().map(|s: &String| &s[..]).collect(); @@ -1358,6 +1381,8 @@ mod roundtrip_vectors { extern crate quickcheck; extern crate flatbuffers; + use alloc::vec::Vec; + #[cfg(not(miri))] // slow. #[test] fn fuzz_manual_build() { @@ -1409,8 +1434,11 @@ mod framing_format { } } +#[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 @@ mod roundtrip_table { 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 @@ mod roundtrip_table { #[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 @@ mod roundtrip_table { 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 @@ mod roundtrip_scalars { const N: u64 = 1000; - fn prop(x: T) { - let mut buf = vec![0u8; ::std::mem::size_of::()]; + fn prop(x: T) { + let mut buf = vec![0u8; ::core::mem::size_of::()]; let y = unsafe { flatbuffers::emplace_scalar(&mut buf[..], x); flatbuffers::read_scalar(&buf[..]) @@ -1742,7 +1773,7 @@ mod roundtrip_push_follow_scalars { 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 @@ mod write_and_read_examples { } } +#[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 @@ mod generated_key_comparisons { 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 @@ mod generated_key_comparisons { // 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 @@ mod follow_impls { 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 @@ mod byte_layouts { c: i8, _pad2: [u8; 4], } - assert_eq!(::std::mem::size_of::(), 16); + assert_eq!(::core::mem::size_of::(), 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::()) + ::core::slice::from_raw_parts(*self as *const foo as *const u8, ::core::mem::size_of::()) }; dst.copy_from_slice(src); } @@ -3170,6 +3206,9 @@ mod byte_layouts { #[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: Copy, Clone); @@ -3187,17 +3226,18 @@ mod copy_clone_traits { 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 @@ fn write_example_wire_data_to_file() { f.write_all(b.finished_data()).unwrap(); } +#[cfg(not(feature = "no_std"))] fn load_file(filename: &str) -> Result, 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 af664f258..4d62a4a3f 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;