|
|
|
|
|
by Arnavion
2623 days ago
|
|
>The Rust version makes a new vector, so it does the same minimal amount of copying (well, moving). To be clear, the Rust version does not do any copying or moving of the strings. Both the set and the new Vec contains &'static str, same as the original Vec. But a more realistic example is where the original Vec was of String elements instead of &'static str. The same point would still apply, but the result Vec of &str would borrow from the original Vec of String. If the goal was to produce a Vec of String, then it would need to copy (clone) the Strings from the original Vec. |
|