Re:My experience rewriting Enjarify in Rust
by masklinn on Monday September 19, 2016 @02:37PM
(#12533630)
In Rust, passing a string by value is a move, and it won't copy the backing buffer at most it copies the stack structure (24 bytes) and possibly not even that (depending on the way it's used).
As to why, well because the function asks for it, either because it generically works on values, or because it consumes the string to avoid copying its internal buffer (e.g. https://doc.rust-lang.org/std/string/struct.String.html#meth...), or whatever other reason. Either way that's a completely valid use.
As to why, well because the function asks for it, either because it generically works on values, or because it consumes the string to avoid copying its internal buffer (e.g. https://doc.rust-lang.org/std/string/struct.String.html#meth...), or whatever other reason. Either way that's a completely valid use.