mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 12:04:27 +00:00
Fixes unused imports in Rust code generator (#8828)
* Fixes unused imports in Rust code generator * Regenerates generated schemas
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
extern crate alloc;
|
||||
extern crate flatbuffers;
|
||||
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.")]
|
||||
pub const ENUM_MIN_ANY: u8 = 0;
|
||||
@@ -47,8 +40,8 @@ impl Any {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl core::fmt::Debug for Any {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::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 {
|
||||
@@ -56,24 +49,24 @@ impl core::fmt::Debug for Any {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<'a> flatbuffers::Follow<'a> for Any {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Any {
|
||||
type Inner = Self;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
||||
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::Push for Any {
|
||||
impl ::flatbuffers::Push for Any {
|
||||
type Output = Any;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); }
|
||||
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::EndianScalar for Any {
|
||||
impl ::flatbuffers::EndianScalar for Any {
|
||||
type Scalar = u8;
|
||||
#[inline]
|
||||
fn to_little_endian(self) -> u8 {
|
||||
@@ -87,17 +80,16 @@ impl flatbuffers::EndianScalar for Any {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Verifiable for Any {
|
||||
impl<'a> ::flatbuffers::Verifiable for Any {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
|
||||
use self::flatbuffers::Verifiable;
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
u8::run_verifier(v, pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::SimpleToVerifyInSlice for Any {}
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for Any {}
|
||||
pub(crate) struct AnyUnionTableOffset {}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
@@ -105,8 +97,8 @@ pub(crate) struct AnyUnionTableOffset {}
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub(crate) enum AnyT {
|
||||
NONE,
|
||||
Game(Box<GameT>),
|
||||
Annotations(Box<AnnotationsT>),
|
||||
Game(alloc::boxed::Box<GameT>),
|
||||
Annotations(alloc::boxed::Box<AnnotationsT>),
|
||||
}
|
||||
impl Default for AnyT {
|
||||
fn default() -> Self {
|
||||
@@ -121,7 +113,7 @@ impl AnyT {
|
||||
Self::Annotations(_) => Any::Annotations,
|
||||
}
|
||||
}
|
||||
pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
|
||||
match self {
|
||||
Self::NONE => None,
|
||||
Self::Game(v) => Some(v.pack(fbb).as_union_value()),
|
||||
@@ -129,9 +121,9 @@ impl AnyT {
|
||||
}
|
||||
}
|
||||
/// If the union variant matches, return the owned GameT, setting the union to NONE.
|
||||
pub fn take_game(&mut self) -> Option<Box<GameT>> {
|
||||
pub fn take_game(&mut self) -> Option<alloc::boxed::Box<GameT>> {
|
||||
if let Self::Game(_) = self {
|
||||
let v = core::mem::replace(self, Self::NONE);
|
||||
let v = ::core::mem::replace(self, Self::NONE);
|
||||
if let Self::Game(w) = v {
|
||||
Some(w)
|
||||
} else {
|
||||
@@ -150,9 +142,9 @@ impl AnyT {
|
||||
if let Self::Game(v) = self { Some(v.as_mut()) } else { None }
|
||||
}
|
||||
/// If the union variant matches, return the owned AnnotationsT, setting the union to NONE.
|
||||
pub fn take_annotations(&mut self) -> Option<Box<AnnotationsT>> {
|
||||
pub fn take_annotations(&mut self) -> Option<alloc::boxed::Box<AnnotationsT>> {
|
||||
if let Self::Annotations(_) = self {
|
||||
let v = core::mem::replace(self, Self::NONE);
|
||||
let v = ::core::mem::replace(self, Self::NONE);
|
||||
if let Self::Annotations(w) = v {
|
||||
Some(w)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user