Closed MarkSwanson closed 7 years ago
Thoughts: sometimes macro error messages are wildly misleading - and I believe this is one of those times. I see you're doing essentially this in your complex_mut example. Maybe I just need to alter how I construct AddValue? Will circle back in a bit.
I'm still unable to get this to work. In a nutshell I would like to have multiple collections that contain references to Strings in a single global collection. Thoughts?
Holding references to things inside the collection effectively means you won't be able to add anything to the collection after that point. So unless you're adding all your strings beforehand and then never modifying the collection again, holding direct references to the strings probably isn't going to work.
A String provides a stable address so as long as I never remove anything from the collection I should be good right? (the single backing store collection isn't really global - I just meant it will outlive any collections that refer to it. This lets me 'garbage collect' the backing store at the end of the process/transaction. Edit: my smaller 'reference' collections are now storing *const u8 + len to the String data (boxed stable address). I thought it would be nice if they would be &str - but I haven't checked to see if &str points to the boxed data or the String... I should probably check that :-)
After thinking about it, of course the ref is unstable and different from the internal boxed data. My string cache using *const +len is working fine - and I have no need to use rental to manage that cache. Closing...
I had the idea of creating a string cache using rental. I'm not quite able to get it to work - but I believe my code is correct in spirit. :-) ? The problem is with this single line of code:
Rustc error: