how to use vector::destroy() #91
-
As per title, is it possible to give an example? |
Beta Was this translation helpful? Give feedback.
Answered by
gregnazario
Mar 20, 2024
Replies: 1 comment 1 reply
-
You only have to use it if the value inside the vector is not drop. Usually we put a value in a vector that it is drop so it’ll get released automatically. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tl;dr you won't have to destroy the vector manually, unless the compiler tells you that that the vector was not droppable.
Situations you would need to use destroy
Destroy is only used if the struct does not have
drop
. The purpose here is to prevent losing data without specifically destroying the item.If the item that you're storing is not
drop
then you'll have to use destroy. If it'sdrop
it'll get destroyed automatically when you remove it from a resource on chain.If the resource is not
drop
, and you don't destroy it, compilation will fail.Example