-
Notifications
You must be signed in to change notification settings - Fork 47
Closed
Description
I followed the example documented by copying the code for the checksum struct to verify the behavior.
Everything worked fine until i attempted to use a Vec with the count attribute, after which i got the following error
borrow this binding in the pattern to avoid moving the value: `ref `rustc[E0382](https://doc.rust-lang.org/error-index.html#E0382)
section_3.rs(6, 10): original diagnostic
borrow of moved value: `__binrw_generated_var_reader`
value borrowed here after moverustc[Click for full compiler diagnostic](rust-analyzer-diagnostics-view:/diagnostic%20message%20%5B0%5D?0#file%3A%2F%2F%2Fhome%2Fdbrenot%2FDocuments%2Fprojects%2FEXTERNAL%2Fgrib2%2Fsrc%2Fsection_3.rs)
section_3.rs(20, 18): borrow occurs due to use in closure
section_3.rs(6, 10): borrow this binding in the pattern to avoid moving the value: `ref `
borrow of moved value: `__binrw_generated_var_reader`
move occurs because `__binrw_generated_var_reader` has type `&mut R`, which does not implement the `Copy` trait
For completeness sake, here is the full code for the struct as well:
#[derive(BinRead, BinWrite)]
#[br(
stream = r, map_stream = |reader| Checksum::new(reader),
assert(section_number == 3)
)]
pub struct GridDefinitionSection {
pub length: u32,
section_number: u8,
pub grid_definition_source: u8,
pub data_points_length: u32,
pub points_list_length: u8,
pub number_of_points_interpretation: u8,
pub grid_definition_template: GridDefinitionTemplate,
// TODO figure out what this is supposed to be
#[br(count = 15-length)]
pub number_of_points: Vec<u8>
}
What can i do to be able to use the map_stream together with the count attribute?
Metadata
Metadata
Assignees
Labels
No labels