-
I'm playing with FFI and I need to know how to manage correctly some lifetimes.
If I understand correctly, for Mojo, the life of bytes stops as soon as my_struct is not used and in this case, it's just after the first call to "external_func". Trouble is external_func will need bytes to be alive for a longer time but Mojo can't know that and external_func will starts to act funny because the values of bytes may have changed So, my question is : how to manage this kind of lifetime ? an easy answer is to do some useless stuff with my_struct at the end of the block (it's what I do now), but a cleaner way to do that must exists. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
One solution is to put a |
Beta Was this translation helpful? Give feedback.
-
great ! Thanks for the answer. |
Beta Was this translation helpful? Give feedback.
great ! Thanks for the answer.