Does owned make the variable copy on write?

Does the owned specifier make the copy copy on write? fn set_fire(owned text: String) -> String: text += "🔥" return text
2 Replies
rdickert
rdickert•14mo ago
@Yeison Rodriguez The docs seem to say so. Possibly related to your question: https://discord.com/channels/1087530497313357884/1166282705873416222
Heyitsmeguys
Heyitsmeguys•14mo ago
I think owned moves the value (think C++ move semantics and Rust's transfer of ownership). The confusion with Int is that it is small enough to pass in registers, so there is never a need to move them. You can always copy them.
Want results from more Discord servers?
Add your server