From d3b781beae148400d6eb1a821802fe7fd27ebcdb Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Thu, 19 Sep 2024 19:28:06 -0500 Subject: [PATCH] use ALIGN for Push::alignment in struct types --- rust/flatbuffers/src/lib.rs | 2 +- src/idl_gen_rust.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rust/flatbuffers/src/lib.rs b/rust/flatbuffers/src/lib.rs index 7ace5268263..1ded368171c 100644 --- a/rust/flatbuffers/src/lib.rs +++ b/rust/flatbuffers/src/lib.rs @@ -52,7 +52,7 @@ pub use crate::builder::{Allocator, DefaultAllocator, FlatBufferBuilder}; pub use crate::endian_scalar::{emplace_scalar, read_scalar, read_scalar_at, EndianScalar}; pub use crate::follow::{Follow, FollowStart}; pub use crate::primitives::*; -pub use crate::push::Push; +pub use crate::push::{Push, PushAlignment}; pub use crate::table::{buffer_has_identifier, Table}; pub use crate::vector::{follow_cast_ref, Vector, VectorIter}; pub use crate::verifier::{ diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp index a85a7812dc6..a551ec76208 100644 --- a/src/idl_gen_rust.cpp +++ b/src/idl_gen_rust.cpp @@ -2703,6 +2703,10 @@ class RustGenerator : public BaseGenerator { "{{STRUCT_TY}} as *const u8, Self::size());"; code_ += " dst.copy_from_slice(src);"; code_ += " }"; + code_ += " #[inline]"; + code_ += " fn alignment() -> PushAlignment {"; + code_ += " PushAlignment::new({{ALIGN}})"; + code_ += " }"; code_ += "}"; code_ += "";