mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 19:58:17 +00:00
Make flatc generate Rust files not requiring std (#7273)
* Set an explicit 2018 edition for Rust tests * Replace all `std` usage with `core` and `alloc` in Rust code generator * Update the generated files * Make Rust tests actually use no_std when the corresponding feature is enabled
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user