Compare commits

..
Author SHA1 Message Date
Artyom Palvelev 5eb190f000 rust: fix 64-bit scalar wire-format alignment on 32-bit targets in Push::alignment (#9465)
In the FlatBuffers binary wire format specification, every scalar field is
aligned to its own byte size (`1`, `2`, `4`, or `8` bytes), regardless of the
host CPU architecture. Both the `flatc` schema compiler (when computing table
`max_align` and struct field offsets) and the C++ `FlatBufferBuilder::Align` /
`PushElement` implementation align 64-bit scalars (`u64`, `i64`, `f64`) to 8
bytes on all architectures.

However, in the Rust `flatbuffers` crate (`rust/flatbuffers/src/push.rs`), the
`Push` trait provides a default implementation:

```rust
fn alignment() -> PushAlignment {
    PushAlignment::new(align_of::<Self::Output>())
}
```

And `impl_push_for_endian_scalar!` did not override `Push::alignment()`,
inheriting `core::mem::align_of::<T>()` for all primitive scalar types (`bool`,
`u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `f32`, `f64`).

On 64-bit targets (`x86_64`, `aarch64`) and 32-bit ARM (`armv7`),
`align_of::<u64>() == 8`, so `align_of::<T>()` happens to equal `size_of::<T>()`.
On 32-bit x86 (`i686`, System V i386 ABI), however, the host ABI alignment of
64-bit scalars (`u64`, `i64`, `f64`) is **4 bytes** (`align_of::<u64>() == 4`),
while their FlatBuffer wire-format size and required wire alignment is **8
bytes** (`size_of::<u64>() == 8`).

As a consequence, on 32-bit x86 (`i686`):
1. `FlatBufferBuilder::push::<u64 / i64 / f64>` only aligns the builder's cursor
   and tracks `min_align` to 4 bytes instead of 8 bytes when writing 64-bit
   table fields or vectors of 64-bit scalars.
2. When a table containing a 64-bit scalar field (`uint64`, `int64`, `double`)
   is serialized on `i686`, the field can be placed at a buffer offset that is
   4-byte aligned but not 8-byte aligned.
3. When the resulting FlatBuffer is verified by C++ `flatbuffers::Verifier`
   (which checks `VerifyField<uint64_t>` with `sizeof(uint64_t) == 8` alignment
   when `FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE` / alignment checks are active)
   or transferred to a 64-bit reader, verification fails or unaligned 64-bit
   reads occur.

Fix `impl_push_for_endian_scalar!` to explicitly implement `Push::alignment()`
using `size_of::<$ty>()` so that all endian scalar types always use their
wire-format byte size as their FlatBuffer alignment across all target
architectures.
2026-11-06 15:15:33 -08:00
3 changed files with 103 additions and 84 deletions
+77 -83
View File
@@ -16,22 +16,22 @@ importers:
version: 24.0.3
'@typescript-eslint/eslint-plugin':
specifier: ^8.34.1
version: 8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3))(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
version: 8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0)(typescript@5.8.3))(eslint@9.29.0)(typescript@5.8.3)
'@typescript-eslint/parser':
specifier: ^8.34.1
version: 8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
version: 8.34.1(eslint@9.29.0)(typescript@5.8.3)
esbuild:
specifier: ^0.25.5
version: 0.25.5
eslint:
specifier: ^9.29.0
version: 9.29.0(supports-color@7.2.0)
version: 9.29.0
typescript:
specifier: 5.8.3
version: 5.8.3
typescript-eslint:
specifier: ^8.34.1
version: 8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
version: 8.34.1(eslint@9.29.0)(typescript@5.8.3)
tests/ts:
dependencies:
@@ -239,22 +239,22 @@ packages:
resolution: {integrity: sha512-Z5kJ+wU3oA7MMIqVR9tyZRtjYPr4OC004Q4Rw7pgOKUOKkJfZ3O24nz3WYfGRpMDNmcOi3TwQOmgm7B7Tpii0w==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@humanfs/core@0.19.2':
resolution: {integrity: sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==}
'@humanfs/core@0.19.1':
resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==}
engines: {node: '>=18.18.0'}
'@humanfs/node@0.16.8':
resolution: {integrity: sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==}
engines: {node: '>=18.18.0'}
'@humanfs/types@0.15.0':
resolution: {integrity: sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==}
'@humanfs/node@0.16.6':
resolution: {integrity: sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==}
engines: {node: '>=18.18.0'}
'@humanwhocodes/module-importer@1.0.1':
resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==}
engines: {node: '>=12.22'}
'@humanwhocodes/retry@0.3.1':
resolution: {integrity: sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==}
engines: {node: '>=18.18'}
'@humanwhocodes/retry@0.4.3':
resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==}
engines: {node: '>=18.18'}
@@ -362,11 +362,11 @@ packages:
balanced-match@1.0.2:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
brace-expansion@1.1.21:
resolution: {integrity: sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==}
brace-expansion@1.1.12:
resolution: {integrity: sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==}
brace-expansion@2.1.7:
resolution: {integrity: sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==}
brace-expansion@2.0.2:
resolution: {integrity: sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==}
braces@3.0.3:
resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}
@@ -430,7 +430,6 @@ packages:
eslint@9.29.0:
resolution: {integrity: sha512-GsGizj2Y1rCWDu6XoEekL3RLilp0voSePurjZIkxL3wlm5o5EC9VpgaP7lrCvjnkuLvzFBQWB3vWB3K5KQTveQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options.
hasBin: true
peerDependencies:
jiti: '*'
@@ -543,8 +542,8 @@ packages:
isexe@2.0.0:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
js-yaml@4.3.2:
resolution: {integrity: sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==}
js-yaml@4.1.1:
resolution: {integrity: sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==}
hasBin: true
json-buffer@3.0.1:
@@ -615,8 +614,8 @@ packages:
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
engines: {node: '>=8'}
picomatch@2.3.2:
resolution: {integrity: sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==}
picomatch@2.3.1:
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
engines: {node: '>=8.6'}
prelude-ls@1.2.1:
@@ -784,22 +783,22 @@ snapshots:
'@esbuild/win32-x64@0.25.5':
optional: true
'@eslint-community/eslint-utils@4.4.0(eslint@9.29.0(supports-color@7.2.0))':
'@eslint-community/eslint-utils@4.4.0(eslint@9.29.0)':
dependencies:
eslint: 9.29.0(supports-color@7.2.0)
eslint: 9.29.0
eslint-visitor-keys: 3.4.3
'@eslint-community/eslint-utils@4.7.0(eslint@9.29.0(supports-color@7.2.0))':
'@eslint-community/eslint-utils@4.7.0(eslint@9.29.0)':
dependencies:
eslint: 9.29.0(supports-color@7.2.0)
eslint: 9.29.0
eslint-visitor-keys: 3.4.3
'@eslint-community/regexpp@4.12.1': {}
'@eslint/config-array@0.20.1(supports-color@7.2.0)':
'@eslint/config-array@0.20.1':
dependencies:
'@eslint/object-schema': 2.1.6
debug: 4.3.7(supports-color@7.2.0)
debug: 4.3.7
minimatch: 3.1.5
transitivePeerDependencies:
- supports-color
@@ -814,15 +813,15 @@ snapshots:
dependencies:
'@types/json-schema': 7.0.15
'@eslint/eslintrc@3.3.1(supports-color@7.2.0)':
'@eslint/eslintrc@3.3.1':
dependencies:
ajv: 6.14.0
debug: 4.3.7(supports-color@7.2.0)
debug: 4.3.7
espree: 10.4.0
globals: 14.0.0
ignore: 5.3.2
import-fresh: 3.3.0
js-yaml: 4.3.2
js-yaml: 4.1.1
minimatch: 3.1.5
strip-json-comments: 3.1.1
transitivePeerDependencies:
@@ -837,20 +836,17 @@ snapshots:
'@eslint/core': 0.15.2
levn: 0.4.1
'@humanfs/core@0.19.2':
dependencies:
'@humanfs/types': 0.15.0
'@humanfs/core@0.19.1': {}
'@humanfs/node@0.16.8':
'@humanfs/node@0.16.6':
dependencies:
'@humanfs/core': 0.19.2
'@humanfs/types': 0.15.0
'@humanwhocodes/retry': 0.4.3
'@humanfs/types@0.15.0': {}
'@humanfs/core': 0.19.1
'@humanwhocodes/retry': 0.3.1
'@humanwhocodes/module-importer@1.0.1': {}
'@humanwhocodes/retry@0.3.1': {}
'@humanwhocodes/retry@0.4.3': {}
'@nodelib/fs.scandir@2.1.5':
@@ -873,15 +869,15 @@ snapshots:
dependencies:
undici-types: 7.8.0
'@typescript-eslint/eslint-plugin@8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3))(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)':
'@typescript-eslint/eslint-plugin@8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0)(typescript@5.8.3))(eslint@9.29.0)(typescript@5.8.3)':
dependencies:
'@eslint-community/regexpp': 4.12.1
'@typescript-eslint/parser': 8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
'@typescript-eslint/parser': 8.34.1(eslint@9.29.0)(typescript@5.8.3)
'@typescript-eslint/scope-manager': 8.34.1
'@typescript-eslint/type-utils': 8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
'@typescript-eslint/utils': 8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
'@typescript-eslint/type-utils': 8.34.1(eslint@9.29.0)(typescript@5.8.3)
'@typescript-eslint/utils': 8.34.1(eslint@9.29.0)(typescript@5.8.3)
'@typescript-eslint/visitor-keys': 8.34.1
eslint: 9.29.0(supports-color@7.2.0)
eslint: 9.29.0
graphemer: 1.4.0
ignore: 7.0.5
natural-compare: 1.4.0
@@ -890,23 +886,23 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/parser@8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)':
'@typescript-eslint/parser@8.34.1(eslint@9.29.0)(typescript@5.8.3)':
dependencies:
'@typescript-eslint/scope-manager': 8.34.1
'@typescript-eslint/types': 8.34.1
'@typescript-eslint/typescript-estree': 8.34.1(supports-color@7.2.0)(typescript@5.8.3)
'@typescript-eslint/typescript-estree': 8.34.1(typescript@5.8.3)
'@typescript-eslint/visitor-keys': 8.34.1
debug: 4.3.7(supports-color@7.2.0)
eslint: 9.29.0(supports-color@7.2.0)
debug: 4.3.7
eslint: 9.29.0
typescript: 5.8.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/project-service@8.34.1(supports-color@7.2.0)(typescript@5.8.3)':
'@typescript-eslint/project-service@8.34.1(typescript@5.8.3)':
dependencies:
'@typescript-eslint/tsconfig-utils': 8.34.1(typescript@5.8.3)
'@typescript-eslint/types': 8.34.1
debug: 4.3.7(supports-color@7.2.0)
debug: 4.3.7
typescript: 5.8.3
transitivePeerDependencies:
- supports-color
@@ -920,12 +916,12 @@ snapshots:
dependencies:
typescript: 5.8.3
'@typescript-eslint/type-utils@8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)':
'@typescript-eslint/type-utils@8.34.1(eslint@9.29.0)(typescript@5.8.3)':
dependencies:
'@typescript-eslint/typescript-estree': 8.34.1(supports-color@7.2.0)(typescript@5.8.3)
'@typescript-eslint/utils': 8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
debug: 4.3.7(supports-color@7.2.0)
eslint: 9.29.0(supports-color@7.2.0)
'@typescript-eslint/typescript-estree': 8.34.1(typescript@5.8.3)
'@typescript-eslint/utils': 8.34.1(eslint@9.29.0)(typescript@5.8.3)
debug: 4.3.7
eslint: 9.29.0
ts-api-utils: 2.1.0(typescript@5.8.3)
typescript: 5.8.3
transitivePeerDependencies:
@@ -933,13 +929,13 @@ snapshots:
'@typescript-eslint/types@8.34.1': {}
'@typescript-eslint/typescript-estree@8.34.1(supports-color@7.2.0)(typescript@5.8.3)':
'@typescript-eslint/typescript-estree@8.34.1(typescript@5.8.3)':
dependencies:
'@typescript-eslint/project-service': 8.34.1(supports-color@7.2.0)(typescript@5.8.3)
'@typescript-eslint/project-service': 8.34.1(typescript@5.8.3)
'@typescript-eslint/tsconfig-utils': 8.34.1(typescript@5.8.3)
'@typescript-eslint/types': 8.34.1
'@typescript-eslint/visitor-keys': 8.34.1
debug: 4.3.7(supports-color@7.2.0)
debug: 4.3.7
fast-glob: 3.3.2
is-glob: 4.0.3
minimatch: 9.0.9
@@ -949,13 +945,13 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/utils@8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)':
'@typescript-eslint/utils@8.34.1(eslint@9.29.0)(typescript@5.8.3)':
dependencies:
'@eslint-community/eslint-utils': 4.7.0(eslint@9.29.0(supports-color@7.2.0))
'@eslint-community/eslint-utils': 4.7.0(eslint@9.29.0)
'@typescript-eslint/scope-manager': 8.34.1
'@typescript-eslint/types': 8.34.1
'@typescript-eslint/typescript-estree': 8.34.1(supports-color@7.2.0)(typescript@5.8.3)
eslint: 9.29.0(supports-color@7.2.0)
'@typescript-eslint/typescript-estree': 8.34.1(typescript@5.8.3)
eslint: 9.29.0
typescript: 5.8.3
transitivePeerDependencies:
- supports-color
@@ -986,12 +982,12 @@ snapshots:
balanced-match@1.0.2: {}
brace-expansion@1.1.21:
brace-expansion@1.1.12:
dependencies:
balanced-match: 1.0.2
concat-map: 0.0.1
brace-expansion@2.1.7:
brace-expansion@2.0.2:
dependencies:
balanced-match: 1.0.2
@@ -1020,11 +1016,9 @@ snapshots:
shebang-command: 2.0.0
which: 2.0.2
debug@4.3.7(supports-color@7.2.0):
debug@4.3.7:
dependencies:
ms: 2.1.3
optionalDependencies:
supports-color: 7.2.0
deep-is@0.1.4: {}
@@ -1067,17 +1061,17 @@ snapshots:
eslint-visitor-keys@4.2.1: {}
eslint@9.29.0(supports-color@7.2.0):
eslint@9.29.0:
dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@9.29.0(supports-color@7.2.0))
'@eslint-community/eslint-utils': 4.4.0(eslint@9.29.0)
'@eslint-community/regexpp': 4.12.1
'@eslint/config-array': 0.20.1(supports-color@7.2.0)
'@eslint/config-array': 0.20.1
'@eslint/config-helpers': 0.2.3
'@eslint/core': 0.14.0
'@eslint/eslintrc': 3.3.1(supports-color@7.2.0)
'@eslint/eslintrc': 3.3.1
'@eslint/js': 9.29.0
'@eslint/plugin-kit': 0.3.5
'@humanfs/node': 0.16.8
'@humanfs/node': 0.16.6
'@humanwhocodes/module-importer': 1.0.1
'@humanwhocodes/retry': 0.4.3
'@types/estree': 1.0.8
@@ -1085,7 +1079,7 @@ snapshots:
ajv: 6.14.0
chalk: 4.1.2
cross-spawn: 7.0.6
debug: 4.3.7(supports-color@7.2.0)
debug: 4.3.7
escape-string-regexp: 4.0.0
eslint-scope: 8.4.0
eslint-visitor-keys: 4.2.1
@@ -1198,7 +1192,7 @@ snapshots:
isexe@2.0.0: {}
js-yaml@4.3.2:
js-yaml@4.1.1:
dependencies:
argparse: 2.0.1
@@ -1228,15 +1222,15 @@ snapshots:
micromatch@4.0.8:
dependencies:
braces: 3.0.3
picomatch: 2.3.2
picomatch: 2.3.1
minimatch@3.1.5:
dependencies:
brace-expansion: 1.1.21
brace-expansion: 1.1.12
minimatch@9.0.9:
dependencies:
brace-expansion: 2.1.7
brace-expansion: 2.0.2
ms@2.1.3: {}
@@ -1267,7 +1261,7 @@ snapshots:
path-key@3.1.1: {}
picomatch@2.3.2: {}
picomatch@2.3.1: {}
prelude-ls@1.2.1: {}
@@ -1309,12 +1303,12 @@ snapshots:
dependencies:
prelude-ls: 1.2.1
typescript-eslint@8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3):
typescript-eslint@8.34.1(eslint@9.29.0)(typescript@5.8.3):
dependencies:
'@typescript-eslint/eslint-plugin': 8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3))(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
'@typescript-eslint/parser': 8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
'@typescript-eslint/utils': 8.34.1(eslint@9.29.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.8.3)
eslint: 9.29.0(supports-color@7.2.0)
'@typescript-eslint/eslint-plugin': 8.34.1(@typescript-eslint/parser@8.34.1(eslint@9.29.0)(typescript@5.8.3))(eslint@9.29.0)(typescript@5.8.3)
'@typescript-eslint/parser': 8.34.1(eslint@9.29.0)(typescript@5.8.3)
'@typescript-eslint/utils': 8.34.1(eslint@9.29.0)(typescript@5.8.3)
eslint: 9.29.0
typescript: 5.8.3
transitivePeerDependencies:
- supports-color
+25
View File
@@ -83,6 +83,11 @@ macro_rules! impl_push_for_endian_scalar {
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
emplace_scalar::<$ty>(dst, *self);
}
#[inline]
fn alignment() -> PushAlignment {
PushAlignment::new(size_of::<$ty>())
}
}
};
}
@@ -98,3 +103,23 @@ impl_push_for_endian_scalar!(u64);
impl_push_for_endian_scalar!(i64);
impl_push_for_endian_scalar!(f32);
impl_push_for_endian_scalar!(f64);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn endian_scalar_push_alignment_matches_wire_size() {
assert_eq!(<bool as Push>::alignment().value(), 1);
assert_eq!(<u8 as Push>::alignment().value(), 1);
assert_eq!(<i8 as Push>::alignment().value(), 1);
assert_eq!(<u16 as Push>::alignment().value(), 2);
assert_eq!(<i16 as Push>::alignment().value(), 2);
assert_eq!(<u32 as Push>::alignment().value(), 4);
assert_eq!(<i32 as Push>::alignment().value(), 4);
assert_eq!(<f32 as Push>::alignment().value(), 4);
assert_eq!(<u64 as Push>::alignment().value(), 8);
assert_eq!(<i64 as Push>::alignment().value(), 8);
assert_eq!(<f64 as Push>::alignment().value(), 8);
}
}
@@ -3,6 +3,6 @@
"type": "module",
"private": true,
"devDependencies": {
"lodash": "4.18.1"
"lodash": "4.17.23"
}
}