diff --git a/rust/flatbuffers/src/builder.rs b/rust/flatbuffers/src/builder.rs index 68cb434b7545..fe2caa090079 100644 --- a/rust/flatbuffers/src/builder.rs +++ b/rust/flatbuffers/src/builder.rs @@ -16,10 +16,13 @@ extern crate smallvec; -use std::cmp::max; -use std::marker::PhantomData; -use std::ptr::write_bytes; -use std::slice::from_raw_parts; +use alloc::vec; +use alloc::vec::Vec; + +use core::cmp::max; +use core::marker::PhantomData; +use core::ptr::write_bytes; +use core::slice::from_raw_parts; use endian_scalar::{read_scalar, emplace_scalar}; use primitives::*; @@ -605,7 +608,7 @@ impl<'fbb> FlatBufferBuilder<'fbb> { fn assert_nested(&self, fn_name: &'static str) { // we don't assert that self.field_locs.len() >0 because the vtable // could be empty (e.g. for empty tables, or for all-default values). - debug_assert!(self.nested, format!("incorrect FlatBufferBuilder usage: {} must be called while in a nested state", fn_name)); + debug_assert!(self.nested, "incorrect FlatBufferBuilder usage: {} must be called while in a nested state", fn_name); } #[inline] fn assert_not_nested(&self, msg: &'static str) { diff --git a/rust/flatbuffers/src/endian_scalar.rs b/rust/flatbuffers/src/endian_scalar.rs index 3e7244e09bc8..1187095840fb 100644 --- a/rust/flatbuffers/src/endian_scalar.rs +++ b/rust/flatbuffers/src/endian_scalar.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use std::mem::size_of; +use core::mem::size_of; /// Trait for values that must be stored in little-endian byte order, but /// might be represented in memory as big-endian. Every type that implements diff --git a/rust/flatbuffers/src/follow.rs b/rust/flatbuffers/src/follow.rs index 4d3eff776459..6e7490d39a18 100644 --- a/rust/flatbuffers/src/follow.rs +++ b/rust/flatbuffers/src/follow.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use std::marker::PhantomData; +use core::marker::PhantomData; /// Follow is a trait that allows us to access FlatBuffers in a declarative, /// type safe, and fast way. They compile down to almost no code (after diff --git a/rust/flatbuffers/src/lib.rs b/rust/flatbuffers/src/lib.rs index 5e304344c97c..ba81632bd901 100644 --- a/rust/flatbuffers/src/lib.rs +++ b/rust/flatbuffers/src/lib.rs @@ -28,6 +28,10 @@ //! At this time, to generate Rust code, you will need the latest `master` version of `flatc`, available from here: https://github.com/google/flatbuffers //! (On OSX, you can install FlatBuffers from `HEAD` with the Homebrew package manager.) +#![no_std] + +extern crate alloc; + mod builder; mod endian_scalar; mod follow; diff --git a/rust/flatbuffers/src/primitives.rs b/rust/flatbuffers/src/primitives.rs index 59176b8f83ae..e43740325b3e 100644 --- a/rust/flatbuffers/src/primitives.rs +++ b/rust/flatbuffers/src/primitives.rs @@ -14,9 +14,9 @@ * limitations under the License. */ -use std::marker::PhantomData; -use std::mem::size_of; -use std::ops::Deref; +use core::marker::PhantomData; +use core::mem::size_of; +use core::ops::Deref; use endian_scalar::{emplace_scalar, read_scalar, read_scalar_at}; use follow::Follow; diff --git a/rust/flatbuffers/src/push.rs b/rust/flatbuffers/src/push.rs index 2b307a3a783c..c6c9d790206c 100644 --- a/rust/flatbuffers/src/push.rs +++ b/rust/flatbuffers/src/push.rs @@ -14,8 +14,8 @@ * limitations under the License. */ -use std::cmp::max; -use std::mem::{align_of, size_of}; +use core::cmp::max; +use core::mem::{align_of, size_of}; use endian_scalar::emplace_scalar; diff --git a/rust/flatbuffers/src/vector.rs b/rust/flatbuffers/src/vector.rs index 397089a664ea..0a71de1870f6 100644 --- a/rust/flatbuffers/src/vector.rs +++ b/rust/flatbuffers/src/vector.rs @@ -14,10 +14,10 @@ * limitations under the License. */ -use std::marker::PhantomData; -use std::mem::size_of; -use std::slice::from_raw_parts; -use std::str::from_utf8_unchecked; +use core::marker::PhantomData; +use core::mem::size_of; +use core::slice::from_raw_parts; +use core::str::from_utf8_unchecked; #[cfg(target_endian = "little")] use endian_scalar::EndianScalar; diff --git a/rust/flatbuffers/src/vtable_writer.rs b/rust/flatbuffers/src/vtable_writer.rs index 119f794cd1c7..fa2cb82984ff 100644 --- a/rust/flatbuffers/src/vtable_writer.rs +++ b/rust/flatbuffers/src/vtable_writer.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use std::ptr::write_bytes; +use core::ptr::write_bytes; use endian_scalar::{emplace_scalar, read_scalar}; use primitives::*;