21 lines
536 B
Rust
21 lines
536 B
Rust
// expect: run
|
|
// result: 305419896
|
|
// phase: 6
|
|
// spec: docs/spec/16-standard-library.md §2.3
|
|
module demo.endian
|
|
import std.bytes;
|
|
|
|
fn main() -> u32
|
|
effects []
|
|
{
|
|
var wire: [u8; 6] = zero;
|
|
match std.bytes.write_u32_be(mut wire[1..5], 0x12345678) {
|
|
std.bytes.WriteResult::ok => {}
|
|
std.bytes.WriteResult::short_output => { return 0; }
|
|
}
|
|
match std.bytes.read_u32_be(ref wire[1..5]) {
|
|
std.bytes.ReadU32::ok(value) => { return value; }
|
|
std.bytes.ReadU32::short_input => { return 0; }
|
|
}
|
|
}
|