From d14b7d028aec3d491d9f162fc84aa8f4e51ec814 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 14 Jul 2026 22:36:32 +0100 Subject: Support struct with Int32 in rust-transient-0 --- examples/10-transient-0/output/rust/src/lib.rs | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/10-transient-0/output/rust/src/lib.rs (limited to 'examples/10-transient-0/output/rust/src/lib.rs') diff --git a/examples/10-transient-0/output/rust/src/lib.rs b/examples/10-transient-0/output/rust/src/lib.rs new file mode 100644 index 0000000..865555e --- /dev/null +++ b/examples/10-transient-0/output/rust/src/lib.rs @@ -0,0 +1,33 @@ +pub mod data; + +#[cfg(test)] +mod test { + use std::io::Cursor; + use super::data::StructWithInt32; + use super::data::StructWithInt64; + + #[test] + fn struct_with_int_32() { + let value = StructWithInt32 { a: 10, b: 25 }; + + assert_round_trip_encoding( + value, + super::data::transient_0::encode_struct_with_int_32, + super::data::transient_0::decode_struct_with_int_32, + ); + } + + fn assert_round_trip_encoding( + value: T, + encode: impl Fn(&T, &mut Cursor>), + decode: impl Fn(&mut Cursor>) -> T, + ) { + let mut bytes = Cursor::new(Vec::new()); + encode(&value, &mut bytes); + + bytes.set_position(0); + let decoded_value = decode(&mut bytes); + + assert_eq!(value, decoded_value); + } +} -- cgit v1.2.3