Hey guys, hope you’re doing fine.
Is there any way to either 1) convert a StorageVec to a Vec or 2) directly hand over a StorageVec to a function which should not have storage access. 2) seems a bit counter intuitive, so I hoped I could somehow convert it to a Vec, cannot find any docs about it and a simple code assignment returns an error.
The motivation behind this question is that I just don’t want all my functions to live inside my contract but still need to keep track of the vector in storage.
The allocation models and the significance of using those types are quite different so I don’t think it would make much sense to automagically convert one to the other.
This sounds like an issue which would be best solved using and/or passing around iterators, which we don’t have yet.
That said, as it stands you can probably simply loop through your StorageVec to copy it to a Vec, manipulate it as such, and then copy it back. That is if you don’t mind the runtime cost.
Thank you for the answer, this is exactly what I resorted to for now. Let me add that Braqzen suggested to take a look at Storage Slice (Discord), so there might be a better solution out there, I’ll try soon.