Files
flatbuffers/tests/monster_test/my_game/example/long_enum_generated.rs
Alex Băluț 860d645349 Support Rust edition 2024 (#8638)
* Developers intro how to contribute

* Fix Rust code generation for Rust edition 2024

The errors look like:

```
warning[E0133]: call to unsafe function `fbs::flatbuffers::emplace_scalar` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::follow_cast_ref` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::Follow::follow` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::read_scalar_at` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::root_unchecked` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::size_prefixed_root_unchecked` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::Table::<'a>::new` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `std::slice::from_raw_parts` is unsafe and requires unsafe block
```

* Update goldens

Ran `goldens/generate_goldens.py`

* Regenerate code files

Ran `scripts/generate_code.py`
2025-07-25 23:12:52 +00:00

67 lines
1.7 KiB
Rust

// 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::*;
#[allow(non_upper_case_globals)]
mod bitflags_long_enum {
flatbuffers::bitflags::bitflags! {
#[derive(Default, Debug, Clone, Copy, PartialEq)]
pub struct LongEnum: u64 {
const LongOne = 2;
const LongTwo = 4;
const LongBig = 1099511627776;
}
}
}
pub use self::bitflags_long_enum::LongEnum;
impl<'a> flatbuffers::Follow<'a> for LongEnum {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { flatbuffers::read_scalar_at::<u64>(buf, loc) };
Self::from_bits_retain(b)
}
}
impl flatbuffers::Push for LongEnum {
type Output = LongEnum;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { flatbuffers::emplace_scalar::<u64>(dst, self.bits()); }
}
}
impl flatbuffers::EndianScalar for LongEnum {
type Scalar = u64;
#[inline]
fn to_little_endian(self) -> u64 {
self.bits().to_le()
}
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u64) -> Self {
let b = u64::from_le(v);
Self::from_bits_retain(b)
}
}
impl<'a> flatbuffers::Verifiable for LongEnum {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier, pos: usize
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
u64::run_verifier(v, pos)
}
}
impl flatbuffers::SimpleToVerifyInSlice for LongEnum {}