Why can’t I store a value and a reference to that value in the same struct?

I have a value and I want to store that value and a reference to something inside that value in my own type: struct Thing { count: u32, } struct Combined<‘a>(Thing, &’a u32); fn make_combined<‘a>() -> Combined<‘a> { let thing = Thing { count: 42 }; Combined(thing, &thing.count) } Sometimes, I have a value and … Read more

Managing the lifetimes of garbage-collected objects [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 months ago. The community reviewed whether to reopen this question last month and left it closed: Original close reason(s) were … Read more