-
Hi, I have a problem using zerocopy for mapping raw data to rust structures:
I get following lifetime error: error[E0521]: borrowed data escapes outside of associated function I'm not sure where this 'static lifetime requirements come from. I guess from zerocopy but haven't found the source. Also I wonder how to implement this pattern to in the context of loading a complete file into a large Vec and put a mapped LoadedFile next to it for access the complete file data just via mapping. To my understanding the purpose of zerocopy is exactly to enable something like this but I haven't found a none-trivial example in docs or somewhere else showing how to do this. Best regards, Vasco |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
ok, I think I somewhat understand the problem now, the self-referential struct seem to be a problem which can be solved via self_cell. at least this compiles:
haven't done much testing with it yet though. |
Beta Was this translation helpful? Give feedback.
-
Seems like this is resolved, so I'm closing the discussion, but feel free to reopen! |
Beta Was this translation helpful? Give feedback.
ok, I think I somewhat understand the problem now, the self-referential struct seem to be a problem which can be solved via self_cell. at least this compiles: