summaryrefslogtreecommitdiff
path: root/rust/zerocopy/benches/try_transmute.rs
blob: c0de07a8d094038e46689793ec4125450ea09811 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use zerocopy::Unalign;
use zerocopy_derive::*;

#[path = "formats/coco_static_size.rs"]
mod format;

#[derive(IntoBytes, KnownLayout, Immutable)]
#[repr(C)]
struct MinimalViableSource {
    bytes: [u8; 6],
}

#[unsafe(no_mangle)]
fn bench_try_transmute(source: MinimalViableSource) -> Option<Unalign<format::CocoPacket>> {
    zerocopy::try_transmute!(source).ok()
}