-
|
For a format like this: #[binrw]
pub struct Element(
#[br(map = |x: u8| x as f32 / u8::MAX as f32)]
#[bw(map = |x| (x * u8::MAX as f32) as u8)]
f32,
);
#[binrw]
pub struct Collection(
#[br(count = 10)]
Vec<Element>
);Is it possible to remove the type |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi, thanks for your question! There is no way to apply directives to the inner type of a container. Instead, read a whole collection of |
Beta Was this translation helpful? Give feedback.
Hi, thanks for your question!
There is no way to apply directives to the inner type of a container. Instead, read a whole collection of
Vec<u8>and then use themapdirective to convert the collection into aVec<f32>byc.into_iter().map(|v| …).collect(). Alternatively, if you need to avoid the memory overhead of temporarily holding two copies of the data, you can also write customparse_with/write_withfunctions (theparserandwritermacros help with this).