diff --git a/rust/flatbuffers/src/array.rs b/rust/flatbuffers/src/array.rs index 089557440c..41e809d043 100644 --- a/rust/flatbuffers/src/array.rs +++ b/rust/flatbuffers/src/array.rs @@ -149,7 +149,7 @@ where T: 'a + Follow<'a>, >::Inner: serde::ser::Serialize, { - fn serialize(&self, serializer: S) -> std::result::Result + fn serialize(&self, serializer: S) -> core::result::Result where S: serde::ser::Serializer, { diff --git a/rust/flatbuffers/src/builder.rs b/rust/flatbuffers/src/builder.rs index 2607921a68..4f798f0a3d 100644 --- a/rust/flatbuffers/src/builder.rs +++ b/rust/flatbuffers/src/builder.rs @@ -1228,12 +1228,14 @@ impl IndexMut for [T] { mod tests { use super::*; use core::sync::atomic::{AtomicUsize, Ordering}; + #[cfg(feature = "std")] use std::alloc::{GlobalAlloc, Layout, System}; static ALLOC_COUNT: AtomicUsize = AtomicUsize::new(0); struct CountingAllocator; + #[cfg(feature = "std")] unsafe impl GlobalAlloc for CountingAllocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { ALLOC_COUNT.fetch_add(1, Ordering::Relaxed); @@ -1244,6 +1246,7 @@ mod tests { } } + #[cfg(feature = "std")] #[global_allocator] static GLOBAL: CountingAllocator = CountingAllocator; diff --git a/rust/flatbuffers/src/vector.rs b/rust/flatbuffers/src/vector.rs index 17a3a1698e..b1e1b4dae5 100644 --- a/rust/flatbuffers/src/vector.rs +++ b/rust/flatbuffers/src/vector.rs @@ -337,7 +337,7 @@ where T: 'a + Follow<'a>, >::Inner: serde::ser::Serialize, { - fn serialize(&self, serializer: S) -> std::result::Result + fn serialize(&self, serializer: S) -> core::result::Result where S: serde::ser::Serializer, {