Skip to content

Commit 1c7f3e7

Browse files
committed
notes
1 parent ecce297 commit 1c7f3e7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/manual_metadata_encoding.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ impl MetadataRoundtrip for IndividualMetadata {
6060
let md = &md[size..];
6161
let md = &md[std::mem::size_of::<usize>()..];
6262
let mut phenotypes = vec![];
63+
// NOTE: production code would want to validate that
64+
// the remaining number of bytes are correct
6365
let chunks = md.chunks_exact(std::mem::size_of::<i32>());
6466
for c in chunks {
67+
// Unwrap b/c the conversion cannot fail b/c the chunk size is correct!
6568
let a: [u8; std::mem::size_of::<i32>()] = c.try_into().unwrap();
6669
phenotypes.push(i32::from_le_bytes(a));
6770
}

0 commit comments

Comments
 (0)